// 11/4/2019
// finding max and min

import java.util.Scanner;

public class Maxmin {
  /** read in a list of grades, and print the maximum*/
  
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    // outside of loop, initialize max to first element
    System.out.println("Enter an integer, 999 to exit: ");
    int num = sc.nextInt();
    int max = num; // intialize max to first value
    int min = num; // initialize min to first value
    while (num != 999) {
      // compare the next# to max
      if (num > max)
        max = num;
      if (num < min)
        min = num;
      // read in next # at end (structured read loop)
      System.out.println("Enter an integer, 999 to exit: ");
      num = sc.nextInt();
    }
    System.out.println("highest number is " +  max +
                       ", smallest number is: " + min);   
  }
}