当我执行我的代码时,我的程序在不扫描字符串的情况下终止。
double x, y;
String s;
Scanner scan = new Scanner(System.in);
System.out.println("Enter Number: ");
x = scan.nextDouble();
System.out.println("Enter Number 2: ");
y = scan.nextDouble();
System.out.println("Enter Operater: x,+,/,-");
s = scan.nextLine();
if(s.equals("x"))
{
System.out.print(x * y);
}
else if(s.equals("+"))
{
System.out.print(x + y);
}
else if(s.equals("/"))
{
System.out.print(x / y);
}
else if(s.equals("-"))
{
System.out.print(x - y);
}
scan.close();
我的程序提前结束s = scan.nextline();
怎么会提前结束?