In my program , I have to calculate GPA from given letter-grade and numeric grade.
In the first dialog-box however if I click cancel it gives me numberFormatException null error and if I type string it gives me NumberFormatException input string error.
I have to use try-catch in my program and I have already tried it.Is there anyway I can handle both exception with try-catch method.I also want user to type 1 and 2 for the letter grade and numeric grade option receptively and
nothing else.

And so forth and so forth. You should be able to catch each exception type in a different block. but you could also just catch NumberFormatException and then check what kind from there. Hope this helps

I have only learned single try and catch(just one catch block) , if i want to stop the null error when a user cancels JOptionPane as well give message when they input string , what can I do ? They are both same type of exceptions.
–
user1036587Nov 9 '11 at 1:25

You need to change your thinking, you shouldn't be using a try catch to deal with the null but rather dealing with it: if(userResponseNumerical!=null){ letsTry.dosomething(); }else{//must be null System.exit(0); } Try approaching the problem with this in mind. (sorry can't get the code to display properly)
–
dann.devNov 9 '11 at 2:44