0
import java.util.Scanner;
public class test {
public static void main(String[] args)
{
Scanner input = new Scanner (System.in);
boolean US1 = false;
boolean game;
int score = 1;
int wage = 0;
int fin_score = 0;
String ans;
if (US1 == false)
{
game = false;
System.out.println (score);
System.out.println("Enter a wager");
wage = input.nextInt();
}
if (wage < score)
{
System.out.println ("What is the capital of Liberia?");
ans = input.nextLine();
if (ans.equalsIgnoreCase("Monrovia"))
{
System.out.println ("You got it right!");
System.out.println ("Final score " + fin_score);
}
}
// TODO Auto-generated method stub
}
}
由于某些原因,一旦我输入工资值,代码将打印出“利比里亚的首都是什么?”。然后终止。林不知道是怎么回事,为什么扫描仪不会让我输入的问题扫描仪停止阅读输入
'Scanner'?我没有在您提供的代码中看到“Scanner”。 – awksp
声明“输入”在哪里? – Michelle
[这是一个已知的问题](http://stackoverflow.com/questions/7056749/scanner-issue-when-using-nextline-after-nextxxx) – gtgaxiola