I am doing a practice internet service provider java question and my inner if statements are never executing.
Every time I run the program, charges still equals 0.
Here is my code
int HoursUsed;
String packageChoice;
double charges = 0;
packageChoice = JOptionPane.showInputDialog("Enter the customer's package (A, B, or C):");
HoursUsed = Integer.parseInt(JOptionPane.showInputDialog("Enter the number of hours used:"));
if (packageChoice == "A"){
if (HoursUsed < 10) {
charges = 9.95;
} else {
charges = (HoursUsed - 10) * 2 + 9.95;
}
}else if (packageChoice == "B"){
if (HoursUsed < 20){
charges = 13.95;
}else{
charges = (HoursUsed - 20) + 13.95;
}
}else if (packageChoice == "C"){
charges = 19.95;
}
JOptionPane.showMessageDialog(null,"The charges are " + charges);
Aucun commentaire:
Enregistrer un commentaire