I am supposed to write a program that asks the user to input a series of numbers. The user should enter -99 to end the program. After typing in -99 the program will tell the user what the highest number and the lowest number was after typing in the series of numbers.
import java.util.Scanner; // Needed for the Scanner class
public class LargestAndSmallest
{
public static void main(String[] args)
{
int number;
int max;
int min;
// Create a Scanner object for keyboard input.
Scanner keyboard = new Scanner(System.in);
// Display general instructions.
System.out.println("Enter a series of numbers.");
System.out.println("When you are finished, Enter -99 to end the program.");
System.out.println();
// Get the first number of points.
System.out.print("Enter a value: ");
number = keyboard.nextInt();
// Accumulate the points until -99 is entered.
while (number != -99)
{
// Get the next number of points.
System.out.print("Enter a value: ");
number = keyboard.nextInt();
}
//not sure what should go here :*(
System.out.println("Smallest number: " + min);
System.out.println("Largest number: " + max);
}
}
I am unsure of how to find the minimum and maximum number inputted. If someone could give me some insight and point me in the right direction, I would be very appreciative.
Message was edited by:
wksmdt