Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

**IN C++ LANGUAGE** Overview A cell phone provider has three different subscript

ID: 3750904 • Letter: #

Question

**IN C++ LANGUAGE**

Overview

A cell phone provider has three different subscription packages for its customers:

Package A: The monthly cost is $29.99 and there are 300 available minutes as part of the package for each month. Any additional minutes are $0.32 per minute.

Package B: The monthly cost is $49.99 and there are 750 available minutes as part of the package for each month. Any additional minutes are $0.28 per minute.

Package C: The monthly cost is $59.99 and there are an unlimited number of available minutes.

For this assignment, write a program that will calculate a single monthly bill for a customer.

Basic Program Logic

Prompt the customer for the package that they subscribe to for the month. This is a character value and the possible values are 'A', 'B', or 'C'. For this assignment, assume that the customer will enter a valid subscription package.

Prompt the customer for the number of minutes that they used during the month. This is an integer value that should be 0 or positive. If the customer enters an invalid value, display an error message and get another value from the customer. For this assignment, assume that the customer will enter a valid number of minutes the second time.

Based on the package and number of minutes used during the month, calculate and display the monthly bill amount for the customer.

Program Requirements

At the top of the C++ source code, include a documentation box that resembles the one from programs 1 and 2. This will be a part of every program that is submitted during the semester and this will be the last reminder in the program write-ups.

Include line documentation. There is no need to document every single line, but logical "chunks" of code should be preceded by a line or two that describes what the "chunk" of code does. This will also be a part of every program that is submitted for the remainder of the semester.

The calculated bill amount should be displayed with exactly 2 digits after the decimal point and a leading dollar sign.

Hand in a copy of the source code (the CPP file) using Blackboard.

Output

Run 1

Run 2

Run 3

Run 4

Run 5

Run 6

Explanation / Answer

Step 1 of 3:

Documentation Box:

We use it for giving an overview of functionality of program methods and other details like author, Purpose, included libraries or files. We will create same forGetBill.cpp written in step 2.

Generally we include it in our code file so I will use comment operator(//) here too.

---------- ----------- --------- ---------- ------------

// File Name: GetBill.cpp

// Other Details Todo by you like Name, Course Name, Credits(You can give to Chegg J) etc.

// Purpose: Based on the entered package and number of minutes used during the month, //display the monthly bill amount for the customer.

// Overall Structure of program:

//1. Takes the input as a character

//2. Takes another input as integer

//3. Check if second input is valid

//4. Takes first input as parameter in switch () statement

//5. Checks if input is matched with case.

//6. If Yes, Calculates and prints the bill using corresponding switch() statement

//7. Check for Test case continuity.

//Input and Output:

//(a) input: character for packages type and integer for minutes used

//(b) Output: calculated bill

//Functions and Methods:

//1. switch(input) and break:

// It will take input as package type and will perform:

//(a) Comparison (between input and (‘A’,’B’,’C’)

//(b) If matched- calculate bill and print the value

//(c ) use break statement for exiting switch()

// 2. do while loop;

// for test continuity and

//3. If conditional statements

//4. iostream functions cout and cin

// Included files and external sources :

//None ( You may add if there)

--------- ---------- --------------   -------------------   ------------------------

Note: I have included line documentation in file GetBill.cpp.

Step 2 of 3:

We will go through interactive C++ code for our program.

---------------------------------

File: GetBill.cpp start...

-----------------------------------

#include<iostream>

using namespace std;

int main()

{

char a; // input for condition -exit of code

// We are using do..while() loop for testing more than one tests

do

{

char pack; // Package Type

cout<<"Which package do you have (A, B, or C)?"<<endl;

cin>>pack;

int mins;// No of minutes used

cout<<"How many minutes were used this month?"<<endl;

cin>>mins;

// Check if entered mins is 0 or more

if(mins<0)

{

cout<<"Please enter Minutes used value as 0 or more. So Enter a valid value now.?"<<endl;

cin>>mins;

}

int extra;//Mins used more than limits of package

float bill; // Our bill is float as we need it upto two decimal points

if(mins>=0)

{

// switch statement takes the condition as input. case is reserved keyword in C++

switch(pack)

{

case 'A': // Here 'A' will be compared with input( in our case pack).

//if not matched ,it will ignore any code after it and before next case statement

// if minutes used are more than package limit

if(mins>300)

{

extra=mins-300;// calculate extra minutes

bill=29.99 + (0.32)*extra;// multiply charge per minute and extra min ,then add to default bill

cout<<"The bill is $"<<bill<<endl;//Print the bill

}

// if minutes used are less than package limit

// Note that below is our output in this case and not just a simple cout statement. So it must be in

//block ({ }) otherwise programme may have runtime issues

else

{

cout<<"The bill is $29.99"<<endl;

}

break;// it must be used for exiting switch statement. Otherwise we will go in infinite loop

case 'B':// if package is B

// if minutes used are more than package limit

if(mins>750)

{

extra=mins-750;

bill=49.99 + (0.32)*extra;

cout<<"The bill is $"<<bill<<endl;

}

// if minutes used are less than package limit

else

{

cout<<"The bill is $49.99"<<endl;

}

break;// We must use it while using switch

}

case 'C':

// minutes used doesnt matter in this case. We have default bill of 59.99 for all customers of this package

cout<<"The bill is $59.99"<<endl;

break;   

}

}

cout<<"Do you want to continue for other test( Enter 'Y' for Yes and any other key for No (or) exit the program)?";

cin>>a;

} while (a=='Y');

return 0;

}

------------------------------------------------

End of file GetBill.cpp

------------------------------------------------

Our answer ends here . Below step is for some extra points and information related to code

Step 3 of 3:

I have written above code specifically as per your requirements which include

Both above constraints may be changed using while or (do..while) loop.

In our second input condition(minutes used), if we use do..while(mins>=0) condition , it will never proceed further until user not enters valid input. Same can be implemented in our first input condition(package)

Note:

I have tested all test given in question and they are producing output as expected.

You can check it by testing above code. Feel free to comment for any help. Thanks