import javax.swing.JOptionPane;
public class OE
{
private int userInput;// a whole number
public OE()
{
}
public static void main(final String[]args)
{
OE number=new OE();
number.showDialog();
}
public void showDialog()
{
try
{
userInput = Integer.parseInt(JOptionPane.showInputDialog("Please Enter a Number."));
calculate();
}
catch(final NumberFormatException e)
{
System.err.println("Error : Invalid input.Please type in a numerical value.");
}
}
private void calculate()
{
if ((userInput%2)==0)
{
JOptionPane.showMessageDialog(null,"Even");
}
else
{
JOptionPane.showMessageDialog(null,"Odd");
}
}
}
public class OE
{
private int userInput;// a whole number
public OE()
{
}
public static void main(final String[]args)
{
OE number=new OE();
number.showDialog();
}
public void showDialog()
{
try
{
userInput = Integer.parseInt(JOptionPane.showInputDialog("Please Enter a Number."));
calculate();
}
catch(final NumberFormatException e)
{
System.err.println("Error : Invalid input.Please type in a numerical value.");
}
}
private void calculate()
{
if ((userInput%2)==0)
{
JOptionPane.showMessageDialog(null,"Even");
}
else
{
JOptionPane.showMessageDialog(null,"Odd");
}
}
}
No comments:
Post a Comment