In: Computer Science
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 new project named Advanced23 Project, and save it in the Cpp8\ChaplO folder. Enter your C++ instructions into a source file named Advanced23.cpp. Also enter appropriate comments and any additional instructions required by the compiler. Test the program appropriately.
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 for any number of connections
If you have any problem with the code feel free to comment.
Program
#include <iostream>
using namespace std;
void residentialCustomer();
void businessCustomer();
int main()
{
int choice;
//taking user choice
cout<<"1. Residential Customer"<<endl;
cout<<"2. Business Customer"<<endl;
cout<<"> ";
cin>>choice;
//calling the appropriate method according to user choice
if(choice==1)
residentialCustomer();
else if(choice==2)
businessCustomer();
else
cout<<"Invalid Choice";
}
void residentialCustomer()
{
int channels;
cout<<"Enter the number of premium channels: ";
cin>>channels;
double total = 4.50+30+(5*channels);//calculating resident
fees
cout<<"Processing fee: $4.50"<<endl;
cout<<"Basic service fee: $30"<<endl;
cout<<"Premium channels: $5 per channel"<<endl;
cout<<"Total Cost: $"<<total<<endl;
}
void businessCustomer()
{
int channels, pChannels;
cout<<"Enter the number of channels: ";
cin>>channels;
cout<<"Enter the number of premium channels: ";
cin>>pChannels;
double total=0;
for(int i =1; i<=channels; i++)
{
//calculating normal channels total
if(i<=5)
total = i*80;
else
total = (i*80)+4;
}
total += 16.50+(50*pChannels);//calculating all total including
premium channels
cout<<"Processing fee: $16.50"<<endl;
cout<<"Basic service fee: $80 for the first 5 connections; $4
for each additional connection"<<endl;
cout<<"Premium channels: $50 per channel "<<endl;
cout<<"Total Cost: $"<<total<<endl;
}
Output