Thursday, 1 September 2016

Java Program (Age Comparison)

THREE AGE COMPARISON IN SWING PACKAGE


import javax.swing.JOptionPane;
    class Three_Age{
        public static void main(String[]args) throws Exception{
            String text = JOptionPane.showInputDialog("Enter First Age");
            int Age1 = Integer.parseInt(text);

            String text2 = JOptionPane.showInputDialog("Enter First Age");
            int Age2 = Integer.parseInt(text2);

            String text3 = JOptionPane.showInputDialog("Enter First Age");
            int Age3 = Integer.parseInt(text3);
    
        if( Age1 > Age2 && Age1 > Age3 )
            JOptionPane.showMessageDialog( null, Age1 + " is Greater" );
        if( Age2 > Age1 && Age2 > Age3 )
            JOptionPane.showMessageDialog( null, Age2 + " is Greater" );
        if( Age3 > Age1 && Age3 > Age2 )
            JOptionPane.showMessageDialog(null, Age3 + " is Greater" );
        if ( Age1 < Age2 && Age1 < Age3 )
            JOptionPane.showMessageDialog( null, Age1 + " is Smaller" );
        if( Age2 < Age1 && Age2 < Age3 )
            JOptionPane.showMessageDialog( null, Age2 + " is Smaller" );
        if( Age3 < Age1 && Age3 < Age2 )
            JOptionPane.showMessageDialog(null, Age3 + " is Smaller" );
        }
    }

No comments:

Post a Comment