有人可以帮我解决我的逻辑错误。我很新,真的可以使用一些帮助。它是一个简单的介绍类程序(我想这是非常明显的)。我希望用户留在循环中,除非他们输入 -99 退出。然后它将显示最高和最低的条目。
谢谢你!
import java.util.Scanner;
public class LeastGreatest {
public static void main(String[] args) {
Scanner keyboard = new Scanner(System.in);
int input = 0, high = 0, low = 0;
System.out.println("Welcome to fun with Loops and Numbers!\n");
System.out.println("Please Enter the AN INTEGER: \n");
input = keyboard.nextInt();
high = input;
low = input;
//System.out.println(input);
do
{
System.out.println("Please Enter the AN INTEGER (Press -99 to Exit): \n");
input = keyboard.nextInt();
if (input > high)
{
input = high;
}
if (input < low)
{
input = low;
}
} while(input != -99);
System.out.println("The highest INT entered was: " + high);
System.out.println("The lowest INT entered was: " + low);
System.out.println("Thank You! Goodbye!");
}
}