public void totals(int packages)
{
{
String sun = JOptionPane.showInputDialog("Package 0 (Living Furniture) \n Enter Item Total for Sunday");
try
{
sundays = Integer.parseInt(sun);
if (sundays >50)
JOptionPane.showMessageDialog(null, "Sorry, Maximum Available for Rental is 50.");
}
catch(NumberFormatException e)
{
System.out.println(e.toString());
JOptionPane.showMessageDialog(null, "Please Enter A Valid Rental Amount");
}
}
String mon = JOptionPane.showInputDialog("Package 0 (Living Furniture) \n Enter Item Total for Monday");
monday = Integer.parseInt(mon);
String tues = JOptionPane.showInputDialog("Package 0 (Living Furniture) \n Enter Item Total for Tuesday");
tuesday = Integer.parseInt(tues);
String wed = JOptionPane.showInputDialog("Package 0 (Living Furniture) \n Enter Item Total for Wednesday");
wednesday = Integer.parseInt(wed);
String thurs = JOptionPane.showInputDialog("Package 0 (Living Furniture) \n Enter Item Total for Thursday");
thursday = Integer.parseInt(thurs);
String fri = JOptionPane.showInputDialog("Package 0 (Living Furniture) \n Enter Item Total for Friday");
friday = Integer.parseInt(fri);
String sat = JOptionPane.showInputDialog("Package 0 (Living Furniture) \n Enter Item Total for Saturday");
saturday = Integer.parseInt(sat);
}
I am having problems with my Exception Handling.
I need to limit the input to be less than 50.
If the user enters anything over 50, it will display:
Sorry, Maximum Available for Rental is 50. If the user enters any characters it will display:
Please Enter A Valid Rental Amount I want it to keep repeating the question until the user enters the correct input.
I am trying to use the Exception Handling for each JOptionPane.showInputDialog.
Not sure what I'm doing wrong here. It gives me the wrong input messages for over 50 and characters, but it doesn't let me re-enter the information.
What am I doing wrong?