Originally Posted by
Plural
This statement got me pretty confused.
Can you include the Message Dialog for me so it can clear up my confusion?
That part for the message dialog need not be altered. The code I gave you will reset the value so that when it is passed to showMessageDialog() it doesn't return a negative number.
Also
if(packageLetter=='A' && hoursUsed>10 && totalFee > 13.95)
JOptionPane.showMessageDialog(null,"You would save $" + savingAB +
" if you purchase Package B.");
if(packageLetter=='A' && hoursUsed>10 && totalFee > 19.95)
JOptionPane.showMessageDialog(null,"You would save $" + savingAC +
" if you purchase Package C.");
else
JOptionPane.showMessageDialog(null,"Your monthly bill is $9.95.");
}
You said you had problems with if, else if, else, right?
Well, that last else will go into affect when :
if(packageLetter=='A' && hoursUsed>10 && totalFee > 19.95)
JOptionPane.showMessageDialog(null,"You would save $" + savingAC +
" if you purchase Package C.");
isn't true.
Did you mean:
if(packageLetter=='A' && hoursUsed>10 && totalFee > 13.95)
JOptionPane.showMessageDialog(null,"You would save $" + savingAB +
" if you purchase Package B.");
else if(packageLetter=='A' && hoursUsed>10 && totalFee > 19.95)
JOptionPane.showMessageDialog(null,"You would save $" + savingAC +
" if you purchase Package C.");
else
JOptionPane.showMessageDialog(null,"Your monthly bill is $9.95.");
}
Well, it should perhaps go like this: though I'm not sure where the else at the end goes:
if(packageLetter=='A' && hoursUsed>10 && totalFee > 13.95)
{
if(packageLetter=='A' && hoursUsed>10 && totalFee > 19.95)
JOptionPane.showMessageDialog(null,"You would save $" + savingAC +
" if you purchase Package C.");
else
JOptionPane.showMessageDialog(null,"You would save $" + savingAB +
" if you purchase Package B.");
}
else
JOptionPane.showMessageDialog(null,"Your monthly bill is $9.95.");
}