因此,如果LARGE
不等于Count
,那么LARGE
应该增加,直到Count
和LARGE
具有相同的值。事情发生之后,我的教授想再次输入一个新的整数,然后它会再次循环,但我不知道如何让我的代码回到while
。
if (LARGE == Count)
{
System.out.println ("Large is Equal to Count");
}
while (Count != LARGE)
{
LARGE++;
System.out.println ("Large is " +LARGE);
}
if (LARGE == Count)
{
System.out.println ("Input a new integer to compare")
LARGE = input.newInt();
}
答案 0 :(得分:0)
根据我的理解,这就是你想要的。
public static void main(String[] args) {
int LARGE = 0;
int Count = 0;
String s = null;
Scanner sc = new Scanner(System.in);
do {
LARGE = sc.nextInt();
Count = sc.nextInt();
if (LARGE == Count) {
System.out.println("Large is Equal to Count");
} else {
do {
LARGE++;
System.out.println("Large is " + LARGE);
} while (Count != LARGE);
if (LARGE == Count) {
System.out.println("Large is Equal to Count");
System.out.println("Input a new integer to compare");
}
}
System.out.println("Do you want to continue? If yes then Press Y");
s = sc.next();
} while (s.equalsIgnoreCase("Y"));
}
答案 1 :(得分:0)
教授想要永远输入新整数的次数是多少? 我假设它1000次。 如果永远,将'times'替换为true,而其他大括号则为'times'而不是1000分配一些有意义的东西。
System.out.println ("Input a new integer to compare")
LARGE = input.newInt();
int times = 1000; // number of times prof want to enter new integer.
int loop = 0;
while(times > loop ){
while (Count != LARGE)
{
LARGE++;
System.out.println ("Large is " +LARGE);
}
System.out.println ("Input a new integer to compare")
LARGE = input.newInt();
loop++;
}