Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

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;
}

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M9887138

Have any Question?


Related Questions in Computer Engineering

Systems analysis projectpersonal trainer inc owns and

Systems analysis project Personal Trainer, Inc. owns and operates fitness centers in a dozen Midwestern cities. The centers have done well, and the company is planning an international expansion by opening a new "superce ...

What effect does the teacher have on creating a learning

What effect does the teacher have on creating a learning environment with little to no behavior problems?

Remote direct memory access rdma enables efficient memory

Remote Direct Memory Access (RDMA) enables efficient memory access from one computer to another. Read about it using Google Scholar, ACM Digital Library or any professional literature tools. Write a 150-200 words (refere ...

Reading the biographybook where the body meets memory by

Reading the Biography Book : "Where the Body Meets Memory" by David Mura Questions: INFERENCE AND ANALYSIS QUESTION - Mura is particularly interested in using italics and different font types to represent different peopl ...

Na2co3 caoh2 -------gt 2naoh caco3cao h2o ------gt

Na2CO3 + Ca(OH)2 -------> 2NaOH + CaCO3 CaO + H2O ------> Ca(OH)2 What weight in kg of NaOH will be generated if 26.5kg of soda ash is used? How many kg of lime is needed for the reaction?

Question share your favorite open web resource and what

Question : Share your favorite open web resource and what cool tools does it have? What can you learn from it? How will it help as a career resource? What is your favorite learning express or JCA course, tool, or Page. W ...

Why are standards needed in data communication and

Why are standards needed in data communication and networking? What are the advantages and disadvantages of standards? How do standards fit in with regulations at the federal, manufacturing, and organizational levels? Gi ...

Suppose circle is a class derived from the class point now

Suppose, Circle is a class derived from the class Point. Now consider the following statements: Point p[] = new Point[12]; P[0] = new Circle(); Now suppose Circle has a method Area() computing are of a circle, and Point ...

As the school year begins what trends are taking place with

As the school year begins, what trends are taking place with Educational Technology in schools?

Question interface design models please respond to the

Question: "Interface Design Models" Please respond to the following: • Evaluate interface design models and describe design issues across human-computer interaction environments associated with these models. Support your ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As