【发布时间】:2017-10-30 00:46:21
【问题描述】:
我不知道问题出在我的代码中。
当int a 小于int b 时,它不应该一直循环吗?
任何帮助将不胜感激,因为我正在努力学习,这让我很困惑。
我的代码:
import java.util.Scanner;
public class TwoNumbers {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
// Keep prompting the user until the input is correct
do {
System.out.println("Enter two positive integers, the first smaller than the second.");
System.out.print("First: ");
int a = in.nextInt();
System.out.print("Second: ");
int b = in.nextInt();
}while(int a > int b);
// Only print this when the input is correct
System.out.println("You entered " + a + " and " + b);
}
}
【问题讨论】:
-
请 1) 显示完整的错误消息。 2) 展示如何编译和调用此代码。 3)不要将您的整个问题作为块引用发布,因为这不是此选项的用途,并且会减损您的问题。
-
请先修复编译错误...
标签: java