Write a complete c program that reworks your cellular bill


Write a complete C++ program that reworks your Cellular Bill calculation program from Chapter 4. Give your source file a meaningful name, such as CellBillFun.cpp. Your new cell bill program must use 3 functions with parameters, as follows:

 

1.      function calcRegBill - accepts one integer argument for the number of minutes used. Determines and returns the total amount due.

 

2.      function calcPremBill - accepts two integer arguments, for the number of day minutes and number of night minutes used. Determines and returns the total amount due.

 

3.      function printBill - accepts 4 arguments: a string account number, a character service code, an integer total number of minutes used, and an amount due. Note that this is a generic print bill function, which prints either a regular or premium bill, using the following format:

Account Number:    XXXXXXX

 

Service Type:          Regular (or Premium, depending on the character received)

 

Total Minutes:         XXXX

 

Amount Due:           $XXX.XX

Your main function will still prompt the user for the account number and service code. Based on the service code, main will ask for the correct number of minutes, then call your functions above as needed to finish the job. In addition you must :

 

  • Correct any logic/calculation errors you had in your previous cellular bill program.

 

  • Incorporate a loop in your program to run the bill as many times as needed. You may do this either by a sentinel controlled loop, or with a counter controlled loop. Make sure all of your control structures are properly indented.

 

  • Run your program with the same test cases as the first Cellular Bill submission.
  • Your output can be directed to the console window.

Here is my program so far, I started to add the functions, but I am not sure how to break up the data into the functions or where to use the loop.

 

// Cell Bill Fun
// April 14, 2013

#include
#include

using namespace std;

double calcRegBill(int a);

double calcPremBill(int b, int c);

void printBill(string acctNumber, char serviceCode, int d, double e);

int main()
{

//declare variables for question 4

    char serviceCode;
    int acctNumber;
    int minutes;
    int dayMinutes;
    int nightMinutes;
    int charge;
    int dayFee;
    int nightFee;
    double amtDue;


//get input
    cout << "Please enter your information to calculate your cell phone bill ";
    cout << "What is your account number? (please enter a 4-digit number-example 1234): ";
    cin >> acctNumber;
    cout << "Do you have regular or premium service? Enter r for regular service, p for Premium.: ";
    cin >> serviceCode;

//format output
cout<< setprecision(2) << fixed;
//output

switch (serviceCode)
{
    case 'r':{
    cout << "How many minutes did you use?: ";
    cin >> minutes;
        if (minutes <= 50)
        amtDue = 10;
        else if (minutes > 50)
         amtDue=10+((minutes-50)*.20);
        else
            cout <<"You have input an invalid service code. Please type r for regular or p for premium service." << endl;

    cout <<"Cellular Account #:" << acctNumber << endl;
    cout <<"Type of Service: Regular" << endl;
    cout <<"Total Minutes:" << minutes << endl;
    cout <<"Amount Due: $"<< amtDue << endl;}
    break;

case 'R':{
    cout << "How many minutes did you use?: ";
    cin >> minutes;
        if (minutes <= 50)
        amtDue = 10;
        else if (minutes > 50)
         amtDue=10+((minutes-50)*.20);
        else
            cout <<"You have input an invalid service code. Please type r for regular or p for premium service." << endl;

    cout <<"Cellular Account #:" << acctNumber << endl;
    cout <<"Type of Service: Regular" << endl;
    cout <<"Total Minutes:" << minutes << endl;
    cout <<"Amount Due: $"<< amtDue << endl;}
    break;

    case 'p':
        cout << "How many daytime minutes did you use?";
        cin >> dayMinutes;
        if (dayMinutes <= 75)
        dayFee = 0;
        else if (dayMinutes > 75)
        dayFee=((dayMinutes-75)*.10);
        cout << "How many night time minutes did you use?";
        cin >> nightMinutes;
        if (nightMinutes <= 100)
        nightFee = 0;
        else if (nightMinutes > 100)
        nightFee=((nightMinutes-100)*.05);
        else
            cout <<"You have input an invalid service code. Please type r for regular or p for premium service." << endl;

    cout <<"Cellular Account #:" << acctNumber << endl;
    cout <<"Type of Service: Premium" << endl;
    cout <<"Total Minutes:" <    cout <<"Amount Due: $"<<25<<"+"<    break;

    case 'P':
    cout << "How many daytime minutes did you use?";
        cin >> dayMinutes;
        if (dayMinutes <= 75)
        dayFee = 0;
        else if (dayMinutes > 75)
        dayFee=((dayMinutes-75)*.10);
        cout << "How many night time minutes did you use?";
        cin >> nightMinutes;
        if (nightMinutes <= 100)
        nightFee = 0;
        else if (nightMinutes > 100)
        nightFee=((nightMinutes-100)*.05);
        else
            cout <<"You have input an invalid service code. Please type r for regular or p for premium service." << endl;

    cout <<"Cellular Account #:" << acctNumber << endl;
    cout <<"Type of Service: Premium" << endl;
    cout <<"Total Minutes:" <    cout <<"Amount Due: $"<<25<<"+"<    break;

    default:

    cout << "Invalid Service Code. Enter r for regular service, p for Premium.";

}



    return 0;

}
double calcRegBill(int a)

{


}
double calcPremBill(int b, int c)

{

}

void printBill(string acctNumber, char serviceCode, int d, double e )
{


return;
}

Request for Solution File

Ask an Expert for Answer!!
Basic Computer Science: Write a complete c program that reworks your cellular bill
Reference No:- TGS0646506

Expected delivery within 24 Hours