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

  Design the logic for a program

Using Visual Logic: Design the logic for a program that allows a user to entry 15 numbers, then displays each number and its difference from the numeric average of the numbers entered.

  Circumstances would you not want to create

Under what circumstances would you not want to create one physical table for every relation in your logical data model? Give a concrete example.

  Why is counter initialization important

Why is counter initialization important?

  Write a recursive

Write a recursive, int -valued function named productOfOdds that accepts an integer array, and the number of elements in the array and returns the product of the odd-valued elements of the array. You may assume the array has at least one odd-value..

  Determine access time when there is cache miss

Determine the access time when there is cache miss? Suppose that cache waits until line has been fetched from main memory and then re-executes for hit.

  Hypothetical business engaged in e-business

Establish a target audience and scope for your presentation. Select a real or hypothetical business engaged in e-business and outline its central offerings and/or services.

  Write the definition of a class counter containing

Write the definition of a class Counter containing: An instance variable named counter of type int . An instance variable named limit of type int . A static int variable named nCounters which is initialized to 0 .

  Write a function print_array()

The program should have a function count() for counting the number of negative elements and the number of non-negative elements of an array, a function split() for splitting the list into negative and non-negative lists, and a function print_array..

  Investigation-woman having inappropriate files on computer

Young woman who was fired from her job for inappropriate files discovered on computer, and she swears she never accessed files. What questions must you ask and how should you proceed?

  Conduct observation used in business or organization

Conduct the observation to someone involved in procedure which is used in a business or organization. This person could be someone at university, in small business in your neighborhood.

  How has configuration for connecting input-output changed

How has the configuration for connecting input/output (I/O) devices to computers on the motherboard changed since the late 1980s?

  Write a calculator program that is able to process an input

Write a calculator program that is able to process an input in postfix notation and give the result. You are free to use the built in stack class or create your own ones.

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