Question

In: Computer Science

In this exercise, you will create a program that displays the amount of a cable bill....

In this exercise, you will create a program that displays the amount of a cable bill. The amount is based on the type of customer shown in figure 10-30. For a residential customer, the user will need to enter the number of premium channels only. For a business customer, the user will need to enter the number of connections and the number of premium channels. Use a separate void function for each customer type. Enter your C++ instructions into the source file and any appropriate comments and any additional instructions required by the compiler. Test the program appropriately.

  • Use pass by reference variables in both functions.
  • Allow the user to enter multiple customers.
  • Before ending the program, show the average charge for both Residential Customers and Business Customers.

FIG10-3

Residential Customers:

Processing Fee: $4.50

Basic Service Fee: $30

Premium Channels: $5 per channel

Business Customers:

Processing Fee: $16.50

Basic Service Fee: $80 for the first 5 connections, $4 for each additional connection

Premium channels: $50 per channel regardless of the number of connections

Solutions

Expert Solution

#include <iostream>
using namespace std;

void residentialCustomer(double &chargeResidential)
{
   int numChannels;
   cout<<"\nEnter the number of premium channels only : ";
   cin>>numChannels;
   chargeResidential = 4.5 + 30.0+ 5*numChannels;
  
}
void businessCustomer(double &chargeBusiness)
{
   int numChannels,numConnections;
   cout<<"\nEnter the number of premium channels : ";
   cin>>numChannels;
   cout<<"\nEnter the number of connections : ";
   cin>>numConnections;
   if(numConnections <= 5)
   chargeBusiness = 16.50 + 80*numConnections+ 50*numChannels;
   else
   chargeBusiness = 16.50 + 84*numConnections+ 50*numChannels;
  
}
int main() {
  
   char customerType;
   double avgChargeResidential = 0;
   double avgChargeBusiness = 0;
   double chargeResidential = 0;
   double chargeBusiness = 0;
   int countR = 0;
   int countB = 0;
  
   do
   {
   cout<<"\nEnter the type of customer < R- Residential customer> or < B - Business Customer> < Z - exit>: ";
   cin>>customerType;
   if(customerType == 'X')
   break;
   switch(customerType)
   {
       case 'R' : residentialCustomer(chargeResidential);
                   cout<<"\nCharges for residential customer : "<<chargeResidential;
                   avgChargeResidential += chargeResidential;
                   countR++;
                   break;
      
       case 'B' : businessCustomer(chargeBusiness);
                   cout<<"\nCharges for business customer : "<<chargeBusiness;
                   avgChargeBusiness += chargeBusiness;
                   countB++;
                   break;
      
       default : cout<<"\nInvalid customer type ";
                   break;
   }
   }while(customerType != 'X');
  
   cout<<"\nAverage charge for residential customers : "<<avgChargeResidential/countR;
   cout<<"\nAverage charge for business customers : "<<avgChargeBusiness/countB;
   return 0;
}

Output:

Enter the type of customer < R- Residential customer> or < B - Business Customer> < Z - exit>: R 
Enter the number of premium channels only : 100
Charges for residential customer : 534.5
Enter the type of customer < R- Residential customer> or < B - Business Customer> < Z - exit>:  B
Enter the number of premium channels : 122
Enter the number of connections : 6
Charges for business customer : 6620.5
Enter the type of customer < R- Residential customer> or < B - Business Customer> < Z - exit>:  R
Enter the number of premium channels only : 150
Charges for residential customer : 784.5
Enter the type of customer < R- Residential customer> or < B - Business Customer> < Z - exit>:  B
Enter the number of premium channels : 150
Enter the number of connections : 3
Charges for business customer : 7756.5
Enter the type of customer < R- Residential customer> or < B - Business Customer> < Z - exit>: X 
Average charge for residential customers : 659.5
Average charge for business customers : 7188.5

Do ask if any doubt. Please upvote.


Related Solutions

In this exercise, you will create a program that displays the amount of a cable bill....
In this exercise, you will create a program that displays the amount of a cable bill. The amount is based on the type of customer, as shown in Figure 10-30. For a residential cus- tomer, the user will need to enter the number of premium channels only. For a business customer, the user will need to enter the number of connections and the number of premium channels. Use a separate void function for each customer type. If necessary, create a...
Create an application that calculates and displays the amount of a homeowner’s property tax. The tax...
Create an application that calculates and displays the amount of a homeowner’s property tax. The tax is 1.35% of the property’s assessed value, which will be entered by the user. a. Prepare a Planning Chart for the application. b. Draw a sketch of an appropriate interface. Be sure to follow the GUI design guidelines covered in the chapter. The guidelines are summarized in Figure 2-20. (If you want to include an image in the interface, you can either use your...
a.Create the logic for a program using pseudocode that calculates and displays the amount of money...
a.Create the logic for a program using pseudocode that calculates and displays the amount of money you would have if you invested $5000 at 2 percent simple interest for one year. Create a separate method to do the calculation and return the result to be displayed. b.Modify the program in Exercise 2a so that the main program prompts the user for the amount of money and passes it to the interest-calculating method. c.Modify the program in Exercise 2b so that...
In C, create a program that displays the minimum and maximum values stored in a data...
In C, create a program that displays the minimum and maximum values stored in a data file "datafile.txt". Use the following function prototype:  void minmaxarray(float value, float *min, float *max);
Create a program in JAVA that displays a design or picture for someone in your quarantine...
Create a program in JAVA that displays a design or picture for someone in your quarantine household/group: a pet, a parent, a sibling, a friend. Make them a picture using the tools in TurtleGraphics and run your program to share it with them! Use a pen object, as well as any of the shape class objects to help you create your design. You must use and draw at least 5 shape objects. - You must use a minimum of 4...
Chapter 8 Programming exercise 6 "Days of each month" Original Exercise: Design a program that displays...
Chapter 8 Programming exercise 6 "Days of each month" Original Exercise: Design a program that displays the number of days in each month. The program’s output should be similar to this: January has 31 days. February has 28 days. March has 31 days. April has 30 days. May has 31 days. June has 30 days. July has 31 days. August has 31 days. September has 30 days. October has 31 days. November has 30 days. December has 31 days. The...
This program will calculate the amount for a semester bill at The University of Nantucket. Part...
This program will calculate the amount for a semester bill at The University of Nantucket. Part 1: Create a class Course.java: The class has non-static instance variables: private String department private int courseNumber private int courseCredits private double courseCost The class must have a default constructor which will set values as follows: department = 0 courseNumber = 0 courseCost = 0 The class must a non-default constructor which will set values as follows: department = value passed to constructor courseNumber...
In this exercise, you create a program for the sales manager at Computer Haven, a small...
In this exercise, you create a program for the sales manager at Computer Haven, a small business that offers motivational seminars to local companies. Figure 7-53 shows the charge for attending a seminar. Notice that the charge per person depends on the number of people the company registers. For example, the cost for four registrants is $400; the cost for two registrants is $300. The program should allow the sales manager to enter the number of registrants for as many...
"Create a program that displays a table consisting of four rows and five columns. The first...
"Create a program that displays a table consisting of four rows and five columns. The first column should display the numbers 1 through 4. The second and sub-sequent columns should display the result of multiplying the number in the first column by the numbers 2 through 5. If necessary, create a new project named Introductory14 Project, and save it in the Cpp8\Chap08 folder. Enter the C++ instructions into a source file named Introductory14.cpp. Also enter appropriate comments and any additional...
Create a program that: Creates a sales receipt, displays the receipt entries and totals, and saves...
Create a program that: Creates a sales receipt, displays the receipt entries and totals, and saves the receipt entries to a file Prompt the user to enter the Item Name Item Quantity Item Price Display the item name, the quantity, and item price, and the extended price (Item Quantity multiplied by Item Price) after the entry is made Save the item name, quantity, item price, and extended price to a file When you create the file, prompt the user for...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT