Purpose of the Program

Making decisions in a program using if...else if.

Exercise

An Internet Service provider has three different subscription packages for its customers:

Package A: For $9.95 per month 10 hours of access are provided. Additional hours are $2.00 per hour.

Package B: For $13.95 per month 20 hours of access are provided. Additional hours are $1.00 per hour.

Package C: For $19.95 per unlimited access is provided.

Write a program that calculates a customers monthly bill. It should ask the user to enter the letter of the package the customer has purchases (A, B, C) and the number of hours that were used. It should then display the total charge.

The program will also calculate and displays the amount of money Package A customers would save if they purchased Package B or C, and the amount of money Package B customers would save if they purchased Package C. If there would be no savings, no message should be printed.

  • This assignment will require using a switch statement to check the different package type (A, B, or C).
  • It requires to use System.out.printf( ) method to output the messages instead of System.out.println( ) or System.out.print( ) or a dialog box.
  • It requires formatting the input and output the same style as shown below in the sample runs.

Notes and Comments

1. The input will be done using the command prompts.

2. The input/output must be done using System.out.printf( ) to get the credit (Do NOT use the System.out.print and System.out.println methods).

3. The switch statement must be used in the program.

4. The formatting in the input and output must be aligned as shown below.

5. Using final keyword to declare named constants for the prices of packages and extra charges (there should be 5 constants in the program).

The file MUST be named as LastnamePass5.java (for example, my last name is Wood it will be named as woodPass5.java). Be sure to compile your program, correct any syntax errors, recompile until no errors, then test the program with different values.

Example Input and Output

Sample Run 1:

Enter the customer's package (A, B, or C): A
Enter the number of hours used: 30
The charges are: $49.95
With package B you would have saved: $26.00
With package C you would have saved: $30.00

Sample Run 2:

Enter the customer's package (A, B, or C): B
Enter the number of hours used: 20
The charges are: $13.95

Sample Run 3:

Enter the customer's package (A, B, or C): B
Enter the number of hours used: 30
The charges are: $23.95
With package C you would have saved: $4.00
Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.