View the step-by-step solution to:

Question

I am trying to make a program that calculates a customer's monthly bill. I got it done okay, but now I have to

add in a switch statement to check the different package types (A B and C) It has to display the amount of money A customers would save if they purchased B or C, and the amount of money B customers would have saved if they chose C. For no savings, no message should be printed. I am required to used the System.out.printf() method. Here is the code I have up until the switch statement.


 import javax.swing.JOptionPane;

  

  public class houghPass5{

 

    public static void main(String[] args) {

   

     String customerPackage;

     int hours;

     double charges; 

      

      

     customerPackage = (JOptionPane.showInputDialog("Enter the customer's package(A, B, or C"));

      

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

      

/* Info for Package A

$9.95 per month 10 hours, additional $2.00 per hour */

       

      if (customerPackage.equals("A")) 

   {      

      if (hours <= 10)

       {

       charges = 9.95;

       JOptionPane.showMessageDialog(null,"Your End of Month Bill Will Be $" + charges, "Message", JOptionPane.INFORMATION_MESSAGE);

       } 

      else

       {

       charges = 9.95 + ((hours - 10) * 2.00);

       JOptionPane.showMessageDialog(null,"YOU WENT OVER YOUR LIMIT!!  Your End of Month Bill Will Be $" + charges, "Message", JOptionPane.INFORMATION_MESSAGE);      

       }      

   }

      

/* INFO for Package B

$13.95 per month 20 hours, additional $1.00 per hour */

      

      else if (customerPackage.equals("B"))

   {

      if (hours <= 20)

       {

       charges = 13.95;

       JOptionPane.showMessageDialog(null,"PLAN B UPGRADED DATA TIME! Your End of Month Bill Will Be $" + charges, "Message", JOptionPane.INFORMATION_MESSAGE);       

       } 

      else

       {

       charges = 13.95 + ((hours - 20) * 1.00);

       JOptionPane.showMessageDialog(null,"YOU WENT OVER YOUR LIMIT!!  Your End of Month Bill Will Be $" + charges, "Message", JOptionPane.INFORMATION_MESSAGE);   

       }       

   }

   

/* INFO for Package 

$19.95 per month for unlimited usage */

      

      else if (customerPackage.equals("C"))

       {

       charges = 19.95;

       JOptionPane.showMessageDialog(null,"UNLIMITED PLAN!! Your End of Month Bill Will Be $" + charges, "Message", JOptionPane.INFORMATION_MESSAGE);

       } 

            

/* Message Dialog for Incorrect Entry

(anything typed other than A, B, or C) */


      else

       {

       JOptionPane.showMessageDialog(null,"OOPS!! Incorrect Entry! Enter Either A, B, or C (Cap-Sensitive)", "ERROR", JOptionPane.ERROR_MESSAGE);

       }

   

  }

}



Now im totally lost! Please help!

Top Answer

Sign up to view the full answer

Why Join Course Hero?

Course Hero has all the homework and study help you need to succeed! We’ve got course-specific notes, study guides, and practice tests along with expert tutors.

-

Educational Resources
  • -

    Study Documents

    Find the best study resources around, tagged to your specific courses. Share your own to gain free Course Hero access.

    Browse Documents
  • -

    Question & Answers

    Get one-on-one homework help from our expert tutors—available online 24/7. Ask your own questions or browse existing Q&A threads. Satisfaction guaranteed!

    Ask a Question