exception handling
this code is the driver code for a program i have been working on, the only problem i have left with it is that with the exception handling. when a string is enteres in either the quantity or price the warning come up but then it goes straight to the nex dialog box instead of repeating the previous question. how can i fix the exception handling so it reverts back to the question it asked when the incorrect value was entered.
publicstaticvoid main(String[] args)
{
String input;
double number;
double invoiceTotal = 0;
Invoice myInvoice[] =new Invoice[3];
for (int index = 0; index < 3; index++)
{
double num = 0;
myInvoice[index] =new Invoice();
input = JOptionPane.showInputDialog("Please enter Part " + (index + 1) +" Number");
myInvoice[index].setPartNumber(input);
input = JOptionPane.showInputDialog("Please enter Part " + (index + 1) +" Description");
myInvoice[index].setDescription(input);
do
{
input = JOptionPane.showInputDialog("Please Enter Quantity of Part " + (index + 1) +" Required");
try
{
number = Double.parseDouble(input);
myInvoice[index].setQuantity(number);
}
catch (NumberFormatException e)
{
JOptionPane.showMessageDialog(null,"You must enter an double");
}
}
while(input=="");//ENDDOWHILELOOP
do
{
input = JOptionPane.showInputDialog("Please enter Part " + (index + 1) +" Price");
try
{
number = Double.parseDouble(input);
myInvoice[index].setPrice(number);
}
catch (NumberFormatException e)
{
JOptionPane.showMessageDialog(null,"You must enter an double");
}
}
while(input=="");
}
invoiceTotal = myInvoice[0].getTotal() + myInvoice[1].getTotal() + myInvoice[2].getTotal();
JOptionPane.showMessageDialog(null,"Part " +"Description " +"Qty " +"Price\n" +
" " + myInvoice[0].getPartNumber() +" " + myInvoice[0].getDescription() +" " +
myInvoice[0].getQuantity() +" " + myInvoice[0].getPrice() +"\n" + myInvoice[1].getPartNumber() +" " + myInvoice[1].getDescription() +" " +
myInvoice[1].getQuantity() +" " + myInvoice[1].getPrice() +"\n" + myInvoice[2].getPartNumber() +" " + myInvoice[2].getDescription() +" " +
myInvoice[2].getQuantity() +" " + myInvoice[2].getPrice() +"\n" +"$" + invoiceTotal);
}
}

