Saturday, 27 August 2016

Java Program

GUI (Swing) Based Even/Odd Number Recognition Java Program


import javax.swing.JOptionPane;
    class SwingEvenOdd{
        public static void main(String[]args) throws Exception{
            String season = JOptionPane.showInputDialog("Enter Number");
            int asd = Integer.parseInt(season);
        

  if(asd % 2 == 1)
                JOptionPane.showMessageDialog(null, "Number " + asd + " is odd");
  if(asd % 2 == 0)
                JOptionPane.showMessageDialog(null, "Number " + asd + " is even");                      
            
        }
    }

No comments:

Post a Comment