编程新手。
我有一个 Java 课程,我正在尝试编写这个程序,但它不停地打印,甚至在我的浏览器中出错!(我使用在线ide)
我的指示: 问:你有多爱我?低于 10 :错误答案等于 10 或更多 = 好答案
我知道该怎么做,但我不希望每次写答案时程序都停止。我希望程序继续运行,直到我有一个 10 +。所以我总是可以输入,直到它是 10+ 10。
这是我的台词:
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner input = new Scanner (System.in);
System.out.println ("how much do you love me out of 10");
int num1 = input.nextInt();
while (true)
if (num1 <= 9) {
System.out.println("Wrong answer");
}
else {
System.out.println ("Good answer");
}
}
}
幕布斯7119047
相关分类