Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This assignment requires you to design, write, test and debug a C++ program on your own for the first time this semester. You will create

This assignment requires you to design, write, test and debug a C++ program on your own for the first time this semester. You will create and submit a program which meets the requirements described in this write-up.

Learning Objectives

  • To gain experience designing, writing and testing your own C++ program

  • To understand the use of library functions to perform interactive I/O

  • To practice output formatting

  • To create arithmetic calculations, logical expressions and selection statements in C++

  • To declare and utilize constants and variables appropriately

    Problem Statement

    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 $14.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.

    Your task is to write a program that calculates a customer's monthly bill. The program must ask the user which package the customer has purchased and how many hours were used for the current month. It must then display the total amount due.

    In addition to calculating the monthly bill for the user's current package, your program must do the following: display how much money Package A customers would save if they purchased packages B or C, and how much money Package B customers would save if they purchased Package C. If there would be no savings, no message will be printed for a particular case.

    Input/Output

    Use entirely interactive I/O in this program, i.e. all input is typed in at the keyboard by the user (person running the program), and all output goes to the console (text output) window.

1

First, your program must print an introductory output title, and then prompt the user for the plan code. Allow for A, B or C, in upper or lower case. Next ask the user for the number of hours and read this as a whole number.

Be sure to read the section on "Bad Data Checking" below.

Remember to use good style in your program following the course guidelines both from in class discussions and in the required handout, and make the program as user-friendly as possible. Make your input prompts and other output clear and well-formatted.

Bad Data Checking

Your program must check for two kinds of bad input data: (1) verify that the user selects only A, B or C for the service package (in upper or lower case) and (2) the number of hours in a month cannot be less than zero and cannot exceed 744 (the number of hours in a month with 31 days).

First, ask the user for the service plan code. If that code is invalid, print an error message and do not ask the user for the number of hours. If the service plan code is valid, do ask the user for the number of hours. If the number of hours entered is invalid, then print an error message indicating that.

You may assume for this program that when asked for a character, the user types a single non- blank character and then hits enter. You may also assume for this program that when asked for a whole number, the user types an integer value and then hits enter.

Calculate the monthly bill amount only if the service plan code entered and the number of hours entered are both valid inputs.

Sample Run Output

Here is a sample output from a run with all valid input data:

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

Welcome to the ISP Billing Calculator -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

Which package does the customer use (A, B, or C)? A How many hours did the customer use last month? 12

The monthly charges are $13.95 Execution Terminated Normally.

Here is a sample run showing what happens when invalid input for the service plan code is received:

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

Welcome to the ISP Billing Calculator -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

2

Which package does the customer use (A, B, or C)? X Package choice input invalid. Execution Terminated Normally.

Here is a sample run showing what happens when the hours input is invalid:

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

Welcome to the ISP Billing Calculator -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

Which package does the customer use (A, B, or C)? C How many hours did the customer use last month? -1

Hours input invalid. Execution Terminated Normally.

Here is a sample run showing what happens when it is advantageous for the user to switch plans:

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

Welcome to the ISP Billing Calculator -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

Which package does the customer use (A, B, or C)? A How many hours did the customer use last month? 87 The charges are $163.95

By switching to Package B you would save $82.00 By switching to Package C you would save $144.00 Execution Terminated Normally. Press any key to continue

Your output must provide all required elements and follow the style guidelines for this course. The output above is just a suggestion which meets the program requirements. You may be creative and display fancier output if you like.

Be sure you have read and followed the C++ Style Guidelines handout, which is a required reading assignment.

Test Data Sets

We suggest that you start by running your program and testing it using the following data. Use a calculator to check your program's results for correctness. Make up your own test data as well, planning how to test the program for all possible cases which may occur.

3

  1. (1) A

  2. (2) B

  3. (3) C

  4. (4) X

  5. (5) A

  6. (6) B

try 5, 10, 17, and 744 try 10, 20, 21 and 745 try various numbers, including -1 your program must not prompt for an hours value here

find and try values which make it better for the user to switch to plan B or C (see one example to try above under sample runs)

find and try values which make it better for the user to switch to plan C

Plan Hours ------ ------

Keep in mind that your program must work correctly for all possible valid data sets, as well as handling the errors described in the preceding section. The graders will run your program and test it with data sets other than those six listed here.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Systems Design Implementation And Management

Authors: Carlos Coronel, Steven Morris

14th Edition

978-0357673034

More Books

Students also viewed these Databases questions

Question

Explain the rationale underlying a DNase I footprinting experiment.

Answered: 1 week ago

Question

What is Accounting?

Answered: 1 week ago

Question

Define organisation chart

Answered: 1 week ago

Question

What are the advantages of planning ?

Answered: 1 week ago

Question

=+b. Would you need to edit down the copy for a smaller-space ad?

Answered: 1 week ago

Question

=+4. About the medium.

Answered: 1 week ago