import
javax.swing.*;
public class Exception2
{
public static void main( String args[] )
{
String ageString;
int age;
System.out.println("Age parsing application");
ageString = JOptionPane.showInputDialog(null, "Enter age
(1-100)", "Entry of age",
JOptionPane.QUESTION_MESSAGE);
try
{
age = Integer.parseInt( ageString );
int ageNextBirthday = (age + 1);
System.out.println("Age now : " + age);
System.out.println("Age next birthday: " + ageNextBirthday);
}
catch (NumberFormatException n)
{
System.out.println("sorry - your age entry of " +
ageString + " is not
a valid integer");
}
System.exit(0);
}
} // class