我如何开始这个布尔代码?
我需要编写一个涉及以下内容的 Java 程序:
提示用户输入以下信息并将输入存储在适当的变量中:
用户是否是左撇子
用户的父亲是否至少有 5 英尺 10 英寸高
用户的年龄 a
使用 JOptionPane.showMessageDialog()
或 System.out.println()
作为输出,打印出以下信息:
) 用户是否是左撇子
b) 用户的父亲是否至少有 5 英尺 10 英寸高
c) a 和 b 中的值是否至少有一个为 true(如果其中一个或两个为 true,则为 true)
d) a 和 b 是否都为 true(如果至少有一个为假)
e) a 和 b 的真值是否相同(如果 a 和 b 都为真,或者 a 和 b 都为假,则为 true)
我是编程新手,不知道从哪里开始。
I need to write a Java program that involves the following:
Prompts the user for the following information and stores the input in appropriate variables:
Whether the user is left-handed
Whether the user's father was at least 5 ft 10 inches tall
The user's age in months
Prints out the following information, using either JOptionPane.showMessageDialog()
or System.out.println()
for the output:
a) Whether the user is left-handed
b) Whether the user's father was at least 5 ft 10 inches tall
c) Whether at least one of the values from a and b are true (true if either or both are true)
d) Whether a and b are both true (false if at least one is false)
e) Whether the truth values of a and b are the same (true if both a and b are true or if both a and b are false)
I am new to programming and am not sure where to begin.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Hello World! 始终是一个很好的起点。它将教您如何创建 java 程序、编译并运行它。从那里,您将需要弄清楚如何
从命令行读取内容,
将字符串转换为布尔值,和
使用条件语句。
不想直接给你答案,因为这听起来像家庭作业。
但是,如果您有代码,并且在使程序正确编译或运行时遇到特定问题,您可以使用
1) 格式良好的代码创建一个问题,并且
2)输出/异常(如果适用)
3)其他相关信息
和人们会尽力帮助......
Hello World! is always a good place to start. It will teach you how to create a java program, compile it, and run it. From there, you are going to need to figure out how to
read things from the command line,
convert Strings to Booleans, and
use conditional statements.
Don't want to give you the answer directly since this sounds like homework.
However, if you have code, and run into a specific problem getting your program to compile or run correctly, you can create a question with
1) well formatted code, and
2) the output/exception if applicable
3) other relevant information
and people will try to help...