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

USING VISUAL STUDIO Write a program that calculates and prints the bill for a ce

ID: 671319 • Letter: U

Question

USING VISUAL STUDIO

Write a program that calculates and prints the bill for a cellular telephone company The company offers two types of service: regular and premium. It's rates vary depending on the type of service and are computed as follows Regular service: $10.00 plus first 50 minutes are free Charges for over 50 minutes are $0.20 per minute Premium service $25.00 plus: a) For calls made from 6:00 am to 6:00 pm,. The first 75 minutes are free; charges for more than 75 minutes are $0.10 per minute b) For calls made from 6:00 pm to 6:00 am., the first 100 minutes are free; charges for more than 100 minutes are $0.05 per minute DESIGN Keep function main simple with necessary.variable declarations and appropriate function calls and a switch statement. Use GLOBAL CONSTANTS for the different rates to be used in your program NO global variables to be used INPUT: Use a void function called getlnput with two reference parameters for account number and service type as explained below Prompt the user to enter an account number (type int), a service code ( type char) A service code of r or R means regular service; A service code of p or P means premium service; Treat any other character as an error Use switch statements to make your appropriate choice COMPUTE: The program should use the following functions to calculate the billing amount a regularBill Function calculates and returns the billing amount for regular service. Return type should bedouble with no formal parameters Prompts the user for the number of minutes the service was used b premiumBill: Value returning function calculates and returns the billing amount for premium service. Return type should be double with no formal Prompt the user for the number of minutes the service was used NOTE For the premium service, the customer may be using the service during the day and the night. Therefore to calculate the bill, you must ask the user to input the number of minutes the service was used during the day and the number of minutes the service was used during the night.

Explanation / Answer

#include <>
#include <iostream>
using namespace std;
const double REG_CHARGES = 10.00;
const int REG_MINUTES = 50;
const double REG_RATE_OVER_50 = 0.20;
const double PREM_SERV_CHARGES = 25.00;
const int PREM_FREE_DAY_MINUTES = 75;
const double PREM_DAY_RATE_OVER_75 = 0.10;
const int PREM_FREE_NIGHT_MINUTES = 100;
const double PREM_NIGHT_RATE_OVER_100 = 0.05;
double regular();
double premium ();
int main(void)
{
int account;
char service_type;
double amount_due=0;
cout << fixed << showpoint;
cout << setprecision(2);
cout << "Enter Account Number" << endl;
cin >> account;
cout << "Enter Service Type: "
<< "R or r (Regular Service), "
<< "P or p (Premium Service): ";
cin >> service_type;
switch (service_type)
{
case 'r':
case 'R':
amount_due = regular();
cout << " Account Number = "
<< account << endl;
cout << "Amount Due = $"
<< amount_due << endl;
break;
case 'p':
case 'P':
amount_due = premium();
cout << "Account number = "
<< account << endl;
cout << "Amount due = $"
<< amount_due << endl;
break;   
default:
cout << "Invalid customer type."
<< endl;
}
return 0;
}
double regular()
{
int minutes;
double bAmount;
cout << "Enter Number of Minutes" << endl;
cin >> minutes;
while (minutes<0)
{
cout << "Enter Number of Minutes" << endl;
cin >> minutes;
}
if (minutes <= REG_MINUTES)
bAmount = REG_CHARGES;
else
bAmount = REG_CHARGES+ (minutes - REG_MINUTES)* REG_RATE_OVER_50;
cout << "Service Type: Regular" << endl;
cout << "Amount Due: $" << bAmount << endl;
return bAmount;
}
double premium()
{
int day_minutes,night_minutes;
double bAmount;
cout << "Enter day time minutes used: ";
cin >> day_minutes;
cout << endl;
cout << "Enter night time minutes used: ";
cin >> night_minutes;
cout << endl;
bAmount = PREM_SERV_CHARGES;
if (day_minutes > PREM_FREE_DAY_MINUTES)
bAmount = bAmount +(day_minutes - PREM_FREE_DAY_MINUTES)* PREM_DAY_RATE_OVER_75;
if (night_minutes > PREM_FREE_NIGHT_MINUTES)
bAmount = bAmount +(night_minutes - PREM_FREE_NIGHT_MINUTES)* PREM_NIGHT_RATE_OVER_100;
cout << "Service Type: Premium" << endl;
cout << "Minutes Service Used (Day): "
<< day_minutes << endl;
cout << "Minutes Service Used (Night): "
<< night_minutes << endl;
return bAmount;
}