Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.39 KB | None | 0 0
  1. public static void main(String[] args) {
  2. String a = JOptionPane.showInputDialog( "Enter the first integer" );
  3. String b = JOptionPane.showInputDialog( "Enter the second integer" );
  4. String c = JOptionPane.showInputDialog( "Enter the third integer" ); //user inputs the three integers in separate dialog boxes and parses them into ints
  5.  
  6. int first = Integer.parseInt( a );
  7. int second = Integer.parseInt( b );
  8. int third = Integer.parseInt( c ); //parses user input into ints
  9.  
  10. int lowest = 0;
  11. int middle = 0;
  12. int highest = 0; //declares final variables
  13.  
  14. if ((first < second) && (first < third)) lowest = first;
  15. if ((second < first) && (second < third)) lowest = second;
  16. if ((third < first) && (third < second)) lowest = third; //sets value of the lowest integer
  17.  
  18. if ((first < second) && (first > third)) middle = first;
  19. if ((first > second) && (first < third)) middle = first;
  20. if ((second < first) && (second > third)) middle = second;
  21. if ((second > first) && (second < third)) middle = second;
  22. if ((third < first) && (third > second)) middle = third;
  23. if ((third > first) && (third < second)) middle = third; //sets value of middle integer
  24.  
  25. if ((first > second) && (first > third)) highest = first;
  26. if ((second > first) && (second > third)) highest = second;
  27. if ((third > first) && (third > second)) highest = third; //sets value of highest integer
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement