Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void main(String[] args) {
- String a = JOptionPane.showInputDialog( "Enter the first integer" );
- String b = JOptionPane.showInputDialog( "Enter the second integer" );
- String c = JOptionPane.showInputDialog( "Enter the third integer" ); //user inputs the three integers in separate dialog boxes and parses them into ints
- int first = Integer.parseInt( a );
- int second = Integer.parseInt( b );
- int third = Integer.parseInt( c ); //parses user input into ints
- int lowest = 0;
- int middle = 0;
- int highest = 0; //declares final variables
- if ((first < second) && (first < third)) lowest = first;
- if ((second < first) && (second < third)) lowest = second;
- if ((third < first) && (third < second)) lowest = third; //sets value of the lowest integer
- if ((first < second) && (first > third)) middle = first;
- if ((first > second) && (first < third)) middle = first;
- if ((second < first) && (second > third)) middle = second;
- if ((second > first) && (second < third)) middle = second;
- if ((third < first) && (third > second)) middle = third;
- if ((third > first) && (third < second)) middle = third; //sets value of middle integer
- if ((first > second) && (first > third)) highest = first;
- if ((second > first) && (second > third)) highest = second;
- if ((third > first) && (third > second)) highest = third; //sets value of highest integer
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement