1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | public static void main(String args[]) { String input = JOptionPane.showInputDialog( "Enter your age" ); int aga = Integer.parseInt(input); if (age >= 18 ){ JOptionPane.showMessageDialog( null , "You are an adult" ); } else { JOptionPane.showMessageDialog( null , "You are a minor" ); } /* Create and display the form */ java.awt.EventQueue.invokeLater( new Runnable() { public void run() { new JTextField_JFrame().setVisible( true ); } }); } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | public static void main(String args[]) { int side1 = Integer.parseInt(JOptionPane.showInputDialog( "Enter the first side" )); int side2 = Integer.parseInt(JOptionPane.showInputDialog( "Enter the second side" )); int side3 = Integer.parseInt(JOptionPane.showInputDialog( "Enter the third side" )); if (side1 == side2 && side2 == side3){ JOptionPane.showMessageDialog( null , "It is an equilateral triangle" ); } else { if (side1 == side2 || side2 == side3) { JOptionPane.showMessageDialog( null , "It is an isosceles triagle" ) } else { JOptionPane.showMessageDialog( null , "It is an scalene triagle" ) } } /* Create and display the form */ java.awt.EventQueue.invokeLater( new Runnable() { public void run() { new JTextField_JFrame().setVisible( true ); } }); } |