CIS 210 Programming Assignment 3 Solution

Assume that the Internet Service provider, Comcast, 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 month unlimited access is provided.

Write a program that calculates a customer’s monthly bill. It should ask the user to enter the letter of the package the customer has purchased (A, B, or C) and the number of hours that were used. It should the display the total charges. In addition, it should display 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.

Please write a program that displays the following information:

·         The amount of money a customer will pay

·         The amount of money a customer will save if he or she purchase Package B or C

·         The amount of money must following a ‘\$’ and have 2 decimal points, such as \$2.00, \$34.56, etc.

Input

This program requires that you read in the following data values:

Ø   The type of Package (a character)

Ø   The number of hours a customer accessed to the Internet.

You will use entirely interactive I/O in this program, that is, all input is typed in at the keyboard by the user (person running the program), and all output goes to the console window. Note that a user may enter a letter other than A, B ,C for type of package. If a user enters a letter other than A, B, C, it must display a warning message and ask the user to enter a letter until he or she enters a valid letter. For example, it displays “Error: invalid package type”.

Test case output: (green texts are user input)

Case 1:

Please enter the letter of the package: A

Please enter the number of hours used: 5

Total Cost is \$9.95

Good bye

Case 2:

Please enter the letter of the package: A

Please enter the number of hours used: 15

Total Cost is \$19.95.

Customer A can save \$6.00 if he purchases package B

Good bye

Case 3:

Please enter the letter of the package: A

Please enter the number of hours used: 12

Total Cost is \$13.95.

Good bye

Case 4:

Please enter the letter of the package: B

Please enter the number of hours used: 18

Total Cost is \$13.95

Good bye

Case 5:

Please enter the letter of the package: B

Please enter the number of hours used: 25

Total Cost is \$18.95

Good bye

Case 6:

Please enter the letter of the package: B

Please enter the number of hours used: 30

Total Cost is \$23.95

Customer A can save \$4.00 if he purchases package C

Good bye

Case 7:

Please enter the letter of the package: C

Please enter the number of hours used: 60

Total Cost is 19.95

Good bye

Miscellaneous

Be sure to read and understand the sections in the Course Syllabus handout on general project requirements. Also be sure to study the style, documentation and formatting guidelines discussed in the Programming Style Guidelines handout and in the lecture.

What File To Turn In and How to Turn In Your Work using Blackboard

You must turn in your Java program source file which must be named as follows:

Use this format: hw3_InternetServiceProvider.java

Hence, file names will look something like "hw3_InternetServiceProvider.java".