Can somebody please help me with my logic error. I am very new and could really use some help. Its a simple program for an intro class (painfully obvious I would imagine). I would like the user to stay in the loop unless they enter -99 to exit. Then it will display the highest and lowest of the entries.
Thank You!
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!");
}
}