Advertisement
Guest User

Untitled

a guest
Apr 7th, 2013
497
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.99 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Test {
  4.  
  5.     public static void main(String[] args) {
  6.         System.out.println("Please enter values:");
  7.         Scanner in = new Scanner(System.in);
  8.        
  9.         double input;
  10.         double largest = Double.NEGATIVE_INFINITY;
  11.         double smallest = Double.POSITIVE_INFINITY;
  12.        
  13.         while(
  14.                 (
  15.                     (input = in.nextDouble()) != 0
  16.                     &&
  17.                     (
  18.                         (
  19.                             (input > largest)
  20.                             &&
  21.                             (largest=input)!=input
  22.                         )
  23.                         ||
  24.                         (
  25.                             (
  26.                                 (input < smallest)
  27.                                 &&
  28.                                 (smallest=input)==input
  29.                             )
  30.                             || true
  31.                         )
  32.                     )
  33.                 )
  34.                 ||
  35.                 (
  36.                     largest == Double.NEGATIVE_INFINITY
  37.                     &&
  38.                     (
  39.                         (largest=0)==0 && (smallest=0)!=0
  40.                     )
  41.                 )
  42.             );
  43.        
  44.         in.close();
  45.        
  46.         System.out.println("The smallest value was " + smallest);
  47.         System.out.println("The largest value was " + largest);
  48.     }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement