Question

In: Computer Science

CSCI 1470 Lab 5 Assignment #3 Topic: Selection (switch statement)) Reading: Chapter 4 Point Value: 15...

CSCI 1470
Lab 5 Assignment #3

Topic: Selection (switch statement))
Reading: Chapter 4
Point Value: 15 points

*Note: Include the following set of comments at the top of your source code for all assignments.

//Your Name

//Brief description of the purpose of the program (Example: Displays student information.)

Assignment: (Save this file as Lab5-3-YourLastName.cpp) A mobile phone service provider has three different subscription packages for its customers:

Package A:

For $39.99 per month 450 minutes are provided. Additional minutes are $0.45 per minute.

Package B:

For $59.99 per month 900 minutes are provided. Additional minutes are $0.40 per minute.

Package C:

For $69.99 per month unlimited minutes provided.

      Write a program that calculates and displays a customer’s monthly bill. Prompt for the customer’s name, the month being billed, which package the customer purchased and how many minutes were used. Display the customer’s bill as shown below in the sample output.

Display a menu to allow the user to enter the desired subscription package. Use a switch statement to calculate the monthly charge based on the package chosen.

  1. Display an “ERROR MESSAGE” if the minutes entered is less than 0. (The customer cannot use a negative amount of time.)
  2. Use the appropriate symbolic constants.

Sample Input/Output:

Please enter the customer's name: Sue Lee

Please enter the current billing month: July

How many minutes were used? 560

Select a subscription package:

1. Package A

2. Package B

3. Package C

4. Quit

Menu Option: 1

The Mobile Phone bill for July

Customer's Name: Sue Lee

Minutes Used: 560

Amount Due: $89.49

Another Sample Input/Output:

Please enter the customer's name: Lisa Miles

Please enter the current billing month: August

How many minutes were used? 700

Select a subscription package:

1. Package A

2. Package B

3. Package C

4. Quit

Menu Option: 7

The valid choices are 1 through 4. Run the

program again and select one of those.

Another Sample Input/Output:

Please enter the customer's name: John Jones

Please enter the current billing month: May

How many minutes were used? 800

Select a subscription package:

1. Package A

2. Package B

3. Package C

4. Quit

Menu Option: 3

The Mobile Phone bill for May

Customer's Name: John Jones

Minutes Used: 800

Amount Due: $69.99

Another Sample Input/Output:

Please enter the customer's name: Karen Hill

Please enter the current billing month: June

How many minutes were used? 500

Select a subscription package:

1. Package A

2. Package B

3. Package C

4. Quit

Menu Option: 4

Program ending.

Another Sample Input/Output:

Please enter the customer's name: Jill Mills

Please enter the current billing month: May

How many minutes were used? 350

Select a subscription package:

1. Package A

2. Package B

3. Package C

4. Quit

Menu Option: 1

The Mobile Phone bill for May

Customer's Name: Jill Mills

Minutes Used: 350

Amount Due: $39.99

Another Sample Input/Output:

Please enter the customer's name: Josh Hayes

Please enter the current billing month: March

How many minutes were used? 850

Select a subscription package:

1. Package A

2. Package B

3. Package C

4. Quit

Menu Option: 2

The Mobile Phone bill for March

Customer's Name: Josh Hayes

Minutes Used: 850

Amount Due: $59.99

Grading Criteria:

· If program does not run, then 0 points for lab grade.

· -1 point – if no name or description of code

· -1 point – if no named constants are used

· -2 points – for inaccurate output item (Amount Due)

· -1 point – for output items not displayed in sample report (Customer Name, Month, Minutes Used, Amount due)

· -2 points – If no input validation with error message for number of minutes

· -1 point – if money values are not displayed with 2 decimal position

· -2 points – If menu is not displayed for user

Solutions

Expert Solution

Please comment, if you need any corrections.Please give a Thumps up if you like the answer.

Program

#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
   const double PACK_A = 39.99; //constant to hold price of pack A
   const double PACK_B = 59.99; //constant to hold price of pack B
   const double PACK_C = 69.99; //constant to hold price of pack C

   int menu_choice;
   float total;
     
   int mins_used;
   string cust_name,bill_month;
   cout<<"Please enter the customer's name: ";
   getline(cin, cust_name);
   cout<<"Please enter the current billing month: ";
   cin>>bill_month;
   cout << "How many mins_used were used? ";
cin >> mins_used;
   cout<<"Select a subscription package:"<<endl<<"1. Package A"<<endl<<"2. Package B"<<endl<<"3. Package C"<<endl<<"4. Quit"<<endl;
cout << "Menu Option: ";
cin >> menu_choice;
  
  
   if (menu_choice >= 1 && menu_choice <= 4)
   {
  
   switch(menu_choice){
case 1: //if user has chosen package A
total += PACK_A; //add A's price to total
if(mins_used>450)
total += (mins_used-450)*0.45; //add to total price of extra mins_used if there are any
break; //break statement to prevent fall-through
case 2: //if user has chosen package B
total += PACK_B; //add B's price to total
if(mins_used>900)
total += (mins_used-900)*0.40; //add to total price of extra mins_used if there are any
break; //break statement to prevent fall-through
case 3: //if user has chosen package C
total += PACK_C; //add C's price to total
break; //break statement to prevent fall-through
   case 4:
       cout<<"Program ending."<<endl;
       exit(0);
}
   cout<<"The Mobile Phone bill for "<<bill_month<<endl;
   cout<<"Customer's Name: "<<cust_name<<endl;
   cout<<"Minutes Used: "<<mins_used<<endl;

//set fixed precision for formatting
cout << setprecision(2) << fixed << showpoint;

//print total owed to company on screen
cout <<"Amount Due: $"<<total<<endl;
}
else{ //following block will execute if menu_choice>4
cout << "The valid choices are 1 through 4. Run the program again and select one of those." << endl;
}
return 0;
}

Output

Please enter the customer's name: Josh Hayes
Please enter the current billing month: March
How many mins_used were used? 850
Select a subscription package:
1. Package A
2. Package B
3. Package C
4. Quit
Menu Option: 2
The Mobile Phone bill for March
Customer's Name: Josh Hayes
Minutes Used: 850
Amount Due: $59.99


Related Solutions

Consider 5 sequentially connected switches labeled switch 1, 2, 3, 4 and 5, and each switch...
Consider 5 sequentially connected switches labeled switch 1, 2, 3, 4 and 5, and each switch has 4 hosts connected to it (total of 20 hosts). If a host on switch #1 made a virtual circuit connection to every other host on the network, how many rows would be in each switch's virtual circuit table?
Cloud Computing In your chapter 5 reading assignment, you will learn all about the components of...
Cloud Computing In your chapter 5 reading assignment, you will learn all about the components of a traditional information technology infrastructure. This includes all the equipment, beyond your desktop or laptop computer, which allows you to communicate and share information with others. Some of this equipment includes cables, servers, network devices, telecommunications lines, data storage systems, and other devices. Many of these components are usually found behind the scenes in a data center. There has been a developing trend in...
Reading Selection is Equiano's Interesting Narrative of the Life of Olaudah Equiano (Must be 4-5 paragraphs)...
Reading Selection is Equiano's Interesting Narrative of the Life of Olaudah Equiano (Must be 4-5 paragraphs) Briefly introduce the writer and the situation that this reading is about. Identify the genre or nature of the reading. Using specific examples or lines within the reading, suggest the author’s key views and key aims for the reading audience. Evaluate the author’s strategy and what you see as the work’s likely effectiveness (or lack of effectiveness) for the target audience. If there is...
Topic 2 Philosophers Contribution - Reading: Chapter 3(BD) Questions to be attempted and presented/discussed in class:...
Topic 2 Philosophers Contribution - Reading: Chapter 3(BD) Questions to be attempted and presented/discussed in class: C Other general Questions on Philosophical Contributions to be attempted: When a business or organisation is economically viable and obeying the law it can be considered to be ethical. Do you agree? Discuss in the context of ethics being based on views about religion, relationships with other people and perception of ourselves. Society can be seen as a voluntary contract among individuals in which...
Week 1 2 3 4 5 6 Value 18 14 15 10 17 15 Using the...
Week 1 2 3 4 5 6 Value 18 14 15 10 17 15 Using the naïve method (most recent value) as the forecast for the next week, compute the following measures of forecast accuracy. (a) Mean absolute error If required, round your answer to one decimal place. (b) Mean squared error If required, round your answer to one decimal place. (c) Mean absolute percentage error If required, round your intermediate calculations and final answer to two decimal places. (d)...
Topic 4: Lab 3 Senses general and vision: discuss the functions and applications of the different...
Topic 4: Lab 3 Senses general and vision: discuss the functions and applications of the different aspects of the senses and tie it into the lab material. Topic 5: Lab 4 smell, taste, and hearing: So think about it. you can include ideas to improve the lab in an online setting, explanations of exactly the why and how of sensation, in other words don't use the word for the different modalities but describe the process. why are balance and hearing...
3. Define Bait and Switch? 4. Describe an environmental impact statement and identify when one is...
3. Define Bait and Switch? 4. Describe an environmental impact statement and identify when one is needed? 5. Explain how environmental laws regulate the use of toxic substances and the disposal of hazardous wastes? Business Law questions.
Chapter 4 Problem 11 Problem 15, part f. in Chapter 3 asks you to construct a...
Chapter 4 Problem 11 Problem 15, part f. in Chapter 3 asks you to construct a five year financial projection for Aquatic Supplies beginning in 2015. The five year projection appears below. a. Calculate Aquatic Supplies's sustainable and actual growth rates in these years.   b. What do these numbers suggest to you? Aquatic Supplies Co. Five Year Projected Income Statements and Balance Sheets Income Statement (in $ millions) Pro Forma Forecasts 2015 - 2019 2014 Assumptions 2015 2016 2017 2018...
After reading chapter 4, identify the major changes that took place in the DSM-5. Do you...
After reading chapter 4, identify the major changes that took place in the DSM-5. Do you think these changes were positive changes? Consider what changes you think might take place when the DSM 6 is published. Make sure to cite your sources.
Consider the following set of numbers: {3, 5, 2, 5, 5, 15, 2, 2, 4, 4,...
Consider the following set of numbers: {3, 5, 2, 5, 5, 15, 2, 2, 4, 4, 20, 4998, 4} 14. The Q3 of this set is: a. 4 b. 5 c. 2 d. 10 15. The Q1 of this set is: a. 4 b. 5 c. 2 d. 2.5 e. 3
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT