Skip to main content

Check whether the given number is even or odd in JAVA

CODING:
import javax.swing.JOptionPane;
class EorO
{
public static void main(String[] args)
{
String a=JOptionPane.showInputDialog(null, "Enter Number...", "Even or ODD" , JOptionPane.PLAIN_MESSAGE);
if(Integer.parseInt(a)%2==0)
 {
  JOptionPane.showMessageDialog(null, a + " is Even Number");
 }
else
 {
  JOptionPane.showMessageDialog(null, a + " is ODD Number");
 }
System.exit(0);
}
}

Comments