When I run my program and enter in the data for age as a letter it closes?
I am using a do while loop to validate the age to ensure the input is between 0-120 and is a number.
I ran my program and entered the first time for testing purposes
125
The input dialog box opened again asking for age so i tried typing
hs
and the whole input dialog box closes.
Where did I go wrong?
I am using a do while loop to validate the age to ensure the input is between 0-120 and is a number.
I ran my program and entered the first time for testing purposes
125
The input dialog box opened again asking for age so i tried typing
hs
and the whole input dialog box closes.
Where did I go wrong?
//panel2 age input dialog
do
{
strInput = JOptionPane.showInputDialog(null, "Enter the persons "
+ "age.");
age = Integer.parseInt(strInput);
//validate age entry between 0-120 input dialog
}
while(age < 0 || age > 120 || strInput.isEmpty());{
JOptionPane.showMessageDialog(null, "Please enter an age between "
+ "0 and 120!");
}