BCIS 5390 Lab 02 Problem Statement
An Internet service provider has three different subscription packages for its customers:
Package A: For $9.95 per month 10 hours are provided. Additional hours are $2.00 per hour.
Package B: For $13.95 per month 20 hours are provided. Additional hours are $1.00 per hour.
Package C: For $19.95 per month unlimited access is provided
Due to increases in delivery of service to certain markets the Internet service provider is adding a surcharge based upon the customer’s zip code. If the first digit of the zip code is ‘3’ then the additional surcharge is $1.50. If the first digit of the zip code is ‘5’ then the additional surcharge is $1.75. Finally, if the first digit of the zip code is ‘8’ then the additional surcharge is $1.95. See notes below for helpful comments for completing this requirement:
See page 88 under the section, Reading a Character, and the combination of the nextLine() and charAt() methods for retrieving a single character using its position within a string. In order to use the charAt() method the zip code must be a String object OR . . .
Zip code can be declared as a numeric data type and the starting value of 3, 5, or 8, can be determined without the use of the nextLine() and charAt() methods
Currently the Internet Service Provider is providing a discount for customers in specific counties. Customers in Comanche County receive a 5% discount, Parker County customers receive a 10% discount, and customers in Erath County receive a 20% discount. The discount amount is applied to the total charge.
Write a program that calculates a customer’s monthly bill. It should ask the user to enter the number of hours that were used, their zip code, their county, and the letter of the package the customer has purchased (A, B, or C). It should then display the base charge for the selected package, additional charges based upon hours used (if applicable), the surcharge based upon the customer’s zip code, the subtotal for the selected package, the discount amount (may be zero), and the total charges for the selected package. The program should include the following functionality related to validation and input using the appropriate decision structure (please avoid the use of the System.exit() method – all decision structures must end naturally at this point):
The number of hours must be greater than zero otherwise an appropriate message is displayed and the program ends
The first character of the zip code must be greater than zero otherwise an appropriate message is displayed and the program ends
The county name must be entered (i.e., cannot be blank) otherwise an appropriate message is displayed and the program ends
The user should be able to enter the county name in uppercase, lowercase, or mixed case. If an incorrect package letter is entered the program should display an error message to the user and the
program ends The program should allow the user to enter either an uppercase or lowercase character for the package
letter
Additionally, the program should also calculate and 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.
Named constants should be used for the cost of each subscription package so that they can easily be updated if they change in the future. Please follow the naming convention provided in the textbook on page 69.
You may use either console or dialog box input/output, but please be consistent in their use (i.e., please do not mix at this time).
All monetary output should be formatted using String.Format (6th ed., 3.10, p. 164) or DecimalFormat class (5th ed., 3.11, p. 174) to display as currency (i.e., leading dollar sign, appropriate comma(s), and two-decimal places).
Use the horizontal tab escape sequence (see Table 2-2, p. 37) to format output to line up appropriately.
Sample input/output has been provided below:
Sample #1:
Enter hours used: 0 Incorrect hours used. Please try again.
Sample #2:
Enter hours used: 10 Enter zip code: 01234 Incorrect zip code entered. Please try again.
Sample #3:
Enter hours used: 10 Enter zip code: 12345 Enter county: County name is required. Please try again.
Sample #4:
Enter hours used: 10 Enter zip code: 76401 Enter county: Erath Enter package type: F Incorrect package entered. Please try again.
Sample #5
Enter hours used: 5 Enter zip code: 12345 Enter county: Winkler Enter package type: A Base Charge for Package A: $9.95 Additional Charge for Package A: $0.00 Surcharge for Zip Code: $0.00 Subtotal for Package A: $9.95 Discount Amount for County: $0.00 Total Charge for Package A: $9.95
Sample #6
Enter hours used: 20 Enter zip code: 12345 Enter county: Winkler Enter package type: A Base Charge for Package A: $9.95 Additional Charge for Package A: $20.00 Surcharge for Zip Code: $0.00 Subtotal for Package A: $29.95 Discount Amount for County: $0.00 Total Charge for Package A: $29.95 Package B Savings: $16.00 Package C Savings: $10.00
Sample #7
Enter hours used: 25 Enter zip code: 76401 Enter county: Erath Enter package type: A Base Charge for Package A: $9.95 Additional Charge for Package A: $30.00 Surcharge for Zip Code: $0.00 Subtotal for Package A: $39.95 Discount Amount for County: $7.99 Total Charge for Package A: $31.96 Package B Savings: $16.80 Package C Savings: $16.00
Sample #8
Enter hours used: 30 Enter zip code: 34567 Enter county: Comanche Enter package type: A Base Charge for Package A: $9.95 Additional Charge for Package A: $40.00 Surcharge for Zip Code: $1.50 Subtotal for Package A: $51.45 Discount Amount for County: $2.57 Total Charge for Package A: $48.88 Package B Savings: $24.70 Package C Savings: $28.50
Sample #9
Enter hours used: 15 Enter zip code: 12345 Enter county: Winkler Enter package type: B Base Charge for Package B: $13.95 Additional Charge for Package B: $0.00 Surcharge for Zip Code: $0.00 Subtotal for Package B: $13.95 Discount Amount for County: $0.00 Total Charge for Package B: $13.95
Sample #10
Enter hours used: 30 Enter zip code: 12345 Enter county: Winkler Enter package type: B Base Charge for Package B: $13.95 Additional Charge for Package B: $10.00 Surcharge for Zip Code: $0.00 Subtotal for Package B: $23.95 Discount Amount for County: $0.00 Total Charge for Package B: $23.95 Package C Savings: $4.00
Sample input/output has been provided below:
Sample #11
Enter hours used: 10 Enter zip code: 76401 Enter county: Erath Enter package type: B Base Charge for Package B: $13.95 Additional Charge for Package B: $0.00 Surcharge for Zip Code: $0.00 Subtotal for Package B: $13.95 Discount Amount for County: $2.79 Total Charge for Package B: $11.16
Sample #12
Enter hours used: 35 Enter zip code: 34567 Enter county: Comanche Enter package type: B Base Charge for Package B: $13.95 Additional Charge for Package B: $15.00 Surcharge for Zip Code: $1.50 Subtotal for Package B: $30.45 Discount Amount for County: $1.52 Total Charge for Package B: $28.93 Package C Savings: $8.55
Sample #13
Enter hours used: 25 Enter zip code: 56789 Enter county: Parker Enter package type: B Base Charge for Package B: $13.95 Additional Charge for Package B: $5.00 Surcharge for Zip Code: $1.75 Subtotal for Package B: $20.70 Discount Amount for County: $2.07 Total Charge for Package B: $18.63
Sample #14
Enter hours used: 40 Enter zip code: 89012 Enter county: Johnson Enter package type: B Base Charge for Package B: $13.95 Additional Charge for Package B: $20.00 Surcharge for Zip Code: $1.95 Subtotal for Package B: $35.90 Discount Amount for County: $0.00 Total Charge for Package B: $35.90 Package C Savings: $14.00
Sample #15
Enter hours used: 25 Enter zip code: 12345 Enter county: Winkler Enter package type: C Base Charge for Package C: $19.95 Surcharge for Zip Code: $0.00 Subtotal for Package C: $19.95 Discount Amount for County: $0.00 Total Charge for Package C: $19.95
Sample #16
Enter hours used: 50 Enter zip code: 76401 Enter county: Erath Enter package type: C Base Charge for Package C: $19.95 Surcharge for Zip Code: $0.00 Subtotal for Package C: $19.95 Discount Amount for County: $3.99 Total Charge for Package C: $15.96
Sample #17
Enter hours used: 15 Enter zip code: 34567 Enter county: Comanche Enter package type: C Base Charge for Package C: $19.95 Surcharge for Zip Code: $1.50 Subtotal for Package C: $21.45 Discount Amount for County: $1.07 Total Charge for Package C: $20.38
Sample #18
Enter hours used: 20 Enter zip code: 89012 Enter county: Johnson Enter package type: C Base Charge for Package C: $19.95 Surcharge for Zip Code: $1.95 Subtotal for Package C: $21.90 Discount Amount for County: $0.00 Total Charge for Package C: $21.90