我遇到了一个小错误,我只是有点困惑。我已经修复了我遇到的许多问题,但无法弄清楚如何运行。对此错误有任何帮助吗?small error
{
int Y = 0;
int N = 0;
public static void main( String[] args ) throws java.lang.Exception
{
Scanner reader = new Scanner(System.in);
System.out.println("Would you like to play a game? [Y] for yes, [N] for no");
int playGame = reader.nextInt();
if ( playGame == 'Y' )
{
System.out.println("Good then lets continue!");
}
else
{
System.out.println("Have a good day!");
}
System.out.println("Would you like to play Pick 3, Pick 4 or Pick 5? [3] for Pick 3,
[4] for Pick 4, [5] for Pick 5");
int pickGame = reader.nextInt();
if ( pickGame == '3' )
{
System.out.println("You have chosen Pick 3 ");
}
}
}

答案 0 :(得分:0)
我强烈建议您在Java input and output methods以及reading input from the user上阅读更多内容,因为您对此缺乏经验。但是看一下你的代码,你似乎对它是如何完成有一个大概的了解。然后,您使用条件语句/循环来检查用户输入并根据该输入做出决定。
我建议您Java Decision Making及更直接地the IF-ELSE statement阅读。
您的目标是学习如何使用条件语句来评估用户的输入并根据它执行操作。
一个简单的例子是
public class Something
{
public static void main( String[] args )
{
Scanner scan = new Scanner(System.in);
String s = scan.next();
int i = scan.nextInt(); //To parse the text into an int
...
}
}