article

Sunday, June 30, 2019

Java Swing if else statement using Netbeans IDE

Java Swing if else statement using Netbeans IDE
 
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);
            }
        });
}
 
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);
            }
        });
}

Related Post