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

For this programming assignment, you will write a program to compute and print t

ID: 3575169 • Letter: F

Question

For this programming assignment, you will write a program to compute and print the mobile phone bill for customers at a wireless carrier. The wireless carrier offers three service plans. The plan details are as follows: Plan A: $79.99 per month plus first 450 free peak-time minutes and unlimited data. Charges for over 450 minutes are $0.45 per minute. Plan B: $50 per month for unlimited minutes and 500 MB of data. 500 MB slowed to 2G speeds when 500 MB has been reached in one monthly billing cycle. No overage charges -just a message that indicates slower speed. Plan C: $28 per month for 500 minutes and 500 MB of data. Charges for over 500 minutes are $0.02 per minute; charges for over 500 MB of data are $0, 023 per MB. All mobile phone plans charge an additional 20% in various fees and taxes. Your program will contain three (3) user-defined functions with the following names and descriptions: read Customer Info: Reads customer data from the input file - one customer at a time. The input file (customers.txt) contains the last name, account number, plan letter, minutes used, and megabytes of data used. Compute Bills: Computes the monthly mobile phone bill based on the plan details display Bills: Prints the mobile phone bill details for each customer, including the customer's last name, account number, plan letter, minutes used, megabytes of data used, subtotal(charges without taxes and fees), and total (charges with 20% in taxes and fees). The bills (containing all customers' bills) should be printed to an output file named .txt Successful completion of this assignment includes (but is not limited to): Use of selection (Chapter 4), repetition (Chapter 5) and user-defined functions (Chapter 6) in this program Properly named .cop file Inclusion of the algorithm used to develop your program as comments within your program A program that compiles and executes properly A program that properly reads data from the input file, computes the monthly phone bills, and display the monthly bills in an output file.

Explanation / Answer

#include <iostream>

#include <iomanip>

#include <cctype>

using namespace std;

void getPln_Mins(char& PLAN, int& MINUTES);

void calBill(char PLAN, int MINUTES, double& F, double& M, double& H, double& P, double& B);

void outBill(char PLAN, int MINUTES, double F, double M, double H, double P, double B, int account);

double const CODE_F = 150.00;    

double const CODE_M = 5.00;      

double const CODE_H = 40.00;      

double const CODE_P = 64.00;      

double const CODE_B = 150.00;    

int main()

{

            int accnt;

            char plan;

            int mins;

            char getPlan;

            int getMinutes;

            double billF;

            double billM;

            double billH;

            double billP;

            double billB;  

            cout << "This program will calculate and show you your cellular phone bill for one month." << endl << endl;

            do {

                        cout << "Please enter your 5 digit account number: ";

                        cin >> accnt;

                        cout << endl;

                        if ((accnt < 10000) || (accnt > 99999))

                                    cout << "Your account number is not valid" << endl << endl;

            } while ((accnt < 10000) || (accnt > 99999));

            getPln_Mins(plan, mins);

            calBill(plan, mins, billF, billM, billH, billP, billB);

            outBill(plan, mins, billF, billM, billH, billP, billB, accnt);

            system("PAUSE");

            return 0;

}

void getPln_Mins(char& PLAN, int& MINUTES)

{

            cout << "AVAILABLE PLANS:" << endl;

            cout << "F " << endl;

            cout << "M " << endl;

            cout << "H" << endl;

            cout << "P" << endl;

            cout << "Bs" << endl << endl;

            cout << "Please choose the your plan: ";

            cin >> PLAN;

            PLAN = toupper(PLAN);

            cout << endl << "Your chosen plan is: " << endl;

            switch (PLAN) {              

            case 'F':

                        cout << "F - Fixed rate plan - $150 flat fee for unlimited minutes (no businesses)" << endl << endl;

                        break;

            case 'M':

                        cout << "M - Per minute plan - $5 per month plus 21 cents per minute" << endl << endl;

                        cout << "Please input your minutes used: ";

                        cin >> MINUTES;

                        for (; MINUTES < 0;)

                        {

                                    cout << "Invalid number, please enter a number above 0: ";

                                    cin >> MINUTES;

                        }

                        cout << endl;

                        break;

            case 'H':

                        cout << "H - Home customer plan - $40/first 600 minutes used, plus 19 cents each additional minute"

                                    << endl << endl;

                        cout << "Please input your minutes used: ";

                        cin >> MINUTES;

                        for (; MINUTES < 0;)

                        {

                                    cout << "Invalid number, please enter a number above 0: ";

                                    cin >> MINUTES;

                        }

                        cout << endl;

                        break;

            case 'P':

                        cout << "P - Home plus customer plan - $64/first 1000 minutes, plus 17 cents each additional minute"

                                    << endl << endl;

                        cout << "Please input your minutes used: ";

                        cin >> MINUTES;

                        for (; MINUTES < 0;)

                        {

                                    cout << "Invalid number, please enter a number above 0: ";

                                    cin >> MINUTES;

                        }

                        cout << endl;

                        break;

            case 'B':

                        cout << "B - Business customer plan - $150 up to 2,000 minutes, $210 up to 3,000 minutes, $240/over 3,000 "

                                    "minutes" << endl << endl;

                        cout << "Please input your minutes used: ";

                        cin >> MINUTES;

                        for (; MINUTES < 0;)

                        {

                                    cout << "Invalid number, please enter a number above 0: ";

                                    cin >> MINUTES;

                        }

                        cout << endl;

                        break;

            default:

                        cout << "Please enter a valid plan letter from above: ";

                        cin >> PLAN;

                        break;

            }        

}        

void calBill(char PLAN, int MINUTES, double& F, double& M, double& H, double& P, double& B)

{

            if (PLAN == 'F')

                        F = CODE_F;

            else if (PLAN == 'M')

                        M = CODE_M + (.21 * MINUTES);

            else if (PLAN == 'H')

            if (MINUTES > 600)

                        H = CODE_H + (.19 * MINUTES);

            else

                        H = CODE_H;

            else if (PLAN == 'P')

            if (MINUTES > 1000)

                        P = CODE_P + (.17 * MINUTES);

            else

                        P = CODE_P;

            else if (PLAN == 'B')

            if (MINUTES <= 2000)

                        B = CODE_B;

            else if (MINUTES <= 3000)

                        B = CODE_B + 60;

            else if (MINUTES > 3000)

                        B = CODE_B + 90;

}

void outBill(char PLAN, int MINUTES, double F, double M, double H, double P, double B, int account)

{

            double total;

            cout << "YOUR MONTHLY BILL" << endl << endl;

            cout << setw(20);

            cout << "Your account number: " << account << endl;

            cout << "Your plan: " << PLAN << endl;

            if (PLAN != 'F')

                        cout << "Your minutes: " << fixed << showpoint << setprecision(2) << setw(20) << MINUTES << endl;

            cout << "Total due: ";

            switch (PLAN) {              

            case 'F':

                        total = F;

                        break;

            case 'M':

                        total = M;

                        break;

            case 'H':

                        total = H;

                        break;

            case 'P':

                        total = P;

                        break;

            case 'B':

                        total = B;

                        break;

            }

            cout << total << endl;

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote