Advertisement
Guest User

misc brah

a guest
Sep 16th, 2014
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.71 KB | None | 0 0
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class LargestSmallest
  9. {
  10.     public static void main (String[] args) throws java.lang.Exception
  11.     {
  12.         Scanner keyboard = new Scanner (System.in);
  13.         System.out.print("Enter a value: ");
  14.         int value;
  15.         int count;
  16.         value = keyboard.nextInt();
  17.        
  18.         int max, min;
  19.         max = min = value;
  20.        
  21.         for (int i = 1; i < 10; i++) {
  22.             System.out.print("Enter a value: ");
  23.             value = keyboard.nextInt ();
  24.             if (max < value)
  25.                 max = value;
  26.             if (min > value)
  27.                 min = value;
  28.         }
  29.        
  30.         System.out.println (max + " " + min);
  31.     }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement