Search code examples
javaswingjoptionpane

Why can't I get a message dialog to show at end?


I can't seem to get the message dialog to show at the end. The program runs with no errors, asks for input and then nothing as if it is ignoring my if statement. Any clue?

input=JOptionPane.showInputDialog("Enter Internet package choice(A,B, or C):");

hours=JOptionPane.showInputDialog("Enter number of hours used:");
rate=Integer.parseInt(hours);

  if(input.equals(a)){

     if(rate>10){
        optionA=(rate-10) * 2.00 +9.95;
        JOptionPane.showMessageDialog(null,"The total is $ " + optionA);}

     else if(rate<=10){
        JOptionPane.showMessageDialog(null,"The total is $ " + 9.95);

Everything is initialized and declared so I'm stumped on this.


Solution

  • input.equals(a) must be returning false. Step thru it in the debugger and see