【发布时间】:2014-10-28 02:03:12
【问题描述】:
我的循环永远不会停止,我似乎无法理解出了什么问题。我正在做 我的班级的一个项目,我对循环很陌生,所以有点困惑。请告诉我如何 来解决这个问题。
import java.util.Scanner;
public class FracCalc {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in); {
boolean Quit = true;
System.out.println("Welcome to FracCalc");
System.out.println("Type expressions with fractions, and I will evaluate them");
String answer = scan.nextLine();
while (Quit = true) {
if (answer.equals("Quit")){
System.out.println("Thanks forr running FracCalc!");
break;
} else {
System.out.println("I can only process 'Quit' for now");
}
}
}
}
}
【问题讨论】:
-
您永远不会将名为“Quit”的变量设置为 false。
标签: java loops if-statement while-loop