Advertisement
JoshJurban

Exercise 6.2A

Oct 23rd, 2014
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.48 KB | None | 0 0
  1. package chapterSix;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class IntegerReaders
  6. {
  7.     public static void main(String[] args)
  8.     {
  9.  
  10.     Scanner s = new Scanner (System.in);
  11.     System.out.println("Inputs:");
  12.     int max = s.nextInt();
  13.     int min = max;
  14.     while (s.hasNextInt())
  15.     {
  16.         int input = s.nextInt();
  17.         if (input > max)
  18.         {
  19.             max = input;
  20.         }
  21.         if (input < min)
  22.         {
  23.             min = input;
  24.         }
  25.        
  26.         System.out.println("Max:"+ max);
  27.         System.out.println("Min:" + min);
  28.     }
  29.     }
  30.    
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement