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

update This program is to compute the cost of telephone calls from a cellular ph

ID: 3679794 • Letter: U

Question

update

This program is to compute the cost of telephone calls from a cellular phone. The cost of individual calls as well as the total bill is to be computed. The cost of the first minute is $0.49; each additional minute costs $0.37. However, time of day discounts will apply depending on the hour the call used. The length of the call should be calculated. Input: The input for each call will be provided by the user. The length of the call should be a float value indicating how long (in minutes) the call lasted. The hour is the float value indicating the time of day the call began. E.g., if the call began at 8:25 am. the input value for that hour should be 8.25; if the call began at 8:25prn, the input hour value should be 20.25. Calculation: The telephone company charges a basic rate of $0.49 for the first minute und $0.37 for each additional minute. The length of time a call lasts is always rounded up. For example, a call with a length of 2.35 would be treated as 3 minutes; a call of length 5.03 would be treated as being 6 minutes long. The basic rate does not always reflect the final cost of the call. The hour the call was placed could result in a discount to the basic rate as follows; Calls starting at after 16, but before or at 22 35% evening discount Calls starting at after 22, but before or at 7 65% evening discount Calls starting at after 7, but before or at 16

Explanation / Answer

1.Program that calculates and prints a bill for a cell phone company

#include <iostream>

#include <iomanip>

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)

{

        

      //Variable Declaration

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;  

}   

2.program to calculate the monthly telephone bills as per the following rule:
Minimum Rs. 200 for upto 100 calls.
Plus Rs. 0.60 per call for next 50 calls.
Plus Rs. 0.50 per call for next 50 calls.
Plus Rs. 0.40 per call for any call beyond 200 calls.

#include<iostream>

using namespace std;

int main()

{

            int calls;

            float bill;

            cout<<"Enter number of calls : ";

            cin>>calls;

            if(calls<=100)

                        bill=200;

            else if (calls>100 && calls<=150)

          {

                        calls=calls-100;

                        bill=200+(0.60*calls);

            }

            else if (calls>150 && calls<=200)

            {

                        calls=calls-150;

                        bill=200+(0.60*50)+(0.50*calls);

            }

            else

            {

                        calls=calls-200;

                        bill=200+(0.60*50)+(0.50*50)+(0.40*calls);

            }

            cout<<" Your bill is Rs."<<bill;

            return 0;

}

Note-By using or by modifying the above 2 programs the given query can be done.