Write a complete c++ program that reworks your cellular bill

Assignment Help Basic Computer Science
Reference no: EM13307820

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 <iostream>
#include <iomanip>

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:" <<dayMinutes+nightMinutes << endl;
    cout <<"Amount Due: $"<<25<<"+"<<dayFee<<"+"<<nightFee<<"= $"<<25+dayFee+nightFee << 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:" <<dayMinutes+nightMinutes << endl;
    cout <<"Amount Due: $"<<25<<"+"<<dayFee<<"+"<<nightFee<<"= $"<<25+dayFee+nightFee << endl;
    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;
}

Reference no: EM13307820

Questions Cloud

Determine the elastic elongation that would be expected : determine the elastic elongation that would be expected for a 16-mm-diameter rod of the same material if the rod were 1.6 m long and subjected to a tension force of 3.3 kN.
Compute the total heat flow into the gas : An ideal gas expands at a constant pressure of 2.1 atm from 446 mL to 844 mL. Heat then flows out of the gas, What is the total heat flow into the gas
Determine the change in each lateral dimension : At the proportional limit, a 32-mm-thick by 87-mm-wide bar elongates 10.2 mm under an axial load of 532 kN. The bar is 2.4 m long. Poisson%u2019s ratio, , for the material is 0.27.
Marketing plan for the purpose of expanding the distribution : Martha Stewart Living Omnimedia and Hain Celestial Group have hired you to develop a marketing plan for the purpose of expanding the distribution of their "Martha Stewart Clean" line of eco-friendly cleaning products to the regions of Asia and South ..
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.
Appeal for acceptance : Appeal for acceptance: On what sort of appeal does the theorist depend to convince people of the theory’s worth? On what sort of evidence or on what kind of appeal does the theory depend to convince people of its worth?
Estimate the final temperature of the iron block : A 3.2-kg block of iron (c=0.11 kcal/kgoC) that has been brought to a temperature of 1,045oC is placed on top of a 2.4-kg block of ice (c=0.5 kcal/kgoC) that has been cooled to -50oC
Calculate value of temperature that can increase efficiency : An engineering student, recognizing that the "ideal gas law" requires gas velocity to be function of temperature, suggests that an easy way to increase efficiency would be to change the temperature of the exhaust gas being treated.
Determine the total heat flow into the gas : An ideal gas expands at a constant pressure of 2.9 atm from 435 mL to 709 mL. Heat then flows out of the gas, determine the total heat flow into the gas

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Disaster recovery planning models

In one page, please Compare and Contrast various Business Continuity & Disaster Recovery Planning models.

  He set of binary strings which are divisible

The set of binary strings which are divisible by 4 when interpreted as an integer value.

  How to do electronic configuration

How to do electronic configuration

  First two training iterations of backpropagation algorithm

Consider a two-layer feedforward ANN with two inputs a and b, one hidden unit c, and one output unit d. This network has five weights (w,, web, wd, wdc, wdO), where w,o represents threshold weight for unit x

  Explaining minor or major virus threats

Write down two recent virus threats, are they minor or major threats? What software would you utilize to remove these threats?

  Evaluate the cost of materials

Evaluate the cost of materials

  What is the paintcomponent method

Describe the types of information available to a program when using the KeyListener interface.

  Shared assets do not bring competitive advantage

Why does Hansen recommend that competition among members should not be issue because shared assets do not bring competitive advantage? Describe.

  Explaining notifier sends e-mail to system administrator

Suppose a notifier sends e-mail to the system administrator when a successful compromise of that system is detected. What are the drawbacks of this approach?

  Describe operating model for business process integration

Describe the chosen operating model in terms of business process integration. Compare the selected organization to the sample organizations using the chosen operating model in terms of business process integration.

  Representing information by predicate-calculus sentences

Represent this information by predicate-calculus sentences in such a way that you can represent the question Is there a member of the alpine club

  How applications of technology used to overcome barrier

Explain how applications of technology could be used as the means to overcome each of these barriers. Write at a minimum the applications which use word processing.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd