Question

Write a program in c++ for An electric company came out with a residential rate schedule...

Write a program in c++ for

An electric company came out with a residential rate schedule in your state. You are asked to write a program that will compute the customer’s electric bill. Program will prompt month number and Kilowatt hour used.

Sample Input Screen:

            Enter the month (1 - 12)                      :

            Kilowatt hours used                             :

The electric bill is computed using the following method:

  1. There is a flat service charge of $15.31 per month.
  2. Table below is used to determine the charge per kilowatt-hour (kwhr).

Kilowatt hours used

Charge per Kilowatt hour

1 - 500 kwhrs

12.9266 cents per kwhr

Over 500 kwhrs

10.9917 cents per kwhr

The program should have the capability to process multiple set of data. Use a do..while statement with the prompt message "Do you want to enter another set? (Y/N)”

You will incorporate an Error trap code to validate the (Y/N) response. If any character other than ‘Y’ or ‘N’ (Ex: s, p….) is entered as response; it will display the message "ERROR: Enter Y/N: “(Refer the tip)

Use system(“cls”); Before the display of the output screen. Use iomanip to display the dollar amounts in two digits after the decimal point. You are required to display the month name, Kilowatt hour used, Service charge, Usage cost and Total bill.

SAMPLE:

            Input data:

            Enter the month (1 - 12)                      :11

            Kilowatt hours used                             :1500

SAMPLE Display:

            Month                                     :November

            Kilowatt hours used                 :1500

            (……………..Blank Line…………………..)

            Flat Service Charge                                           15.31

            Kilowatt usage cost                                        164.88

           

            Total Bill                                              $180.19

TIPS:

  1. (Use switch statement to determine the monthNmae)

switch (month)

{

         case 1: monthName = “January”;

         break;

         …

         …

}

  1. // Does the user want to enter another set of data?

       cout << "Do you want to enter another set? (Y/N)”;

       cin >> again;

       again = toupper(again);

       while ((again != 'Y') && (again != 'N')) //ERROR TRAP

       {

              cout << "ERROR: Enter Y/N: ";

              cin >> again;

              again = toupper(again);

       }

0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include <iostream>
#include <iomanip>

using namespace std;

int main() {
        string months[] = {"", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"};

        char again;
        int month;
        double charges, kw, total;

        do {
                cout << setw(25) << left << "Enter the month(1-12)" << ":";
                cin >> month;
                cout << setw(25) << left << "Kilowatt hours used " << ":";
                cin >> kw;

                if(kw <= 500) {
                        charges = kw * 12.9266 / 100;
                } else {
                        charges = (kw * 10.9917) / 100;
                }
                total = charges + 15.31;

                cout << setprecision(2) << fixed;

                cout << endl;
                cout << setw(25) << left << "Month" << ":" << months[month] << endl;
                cout << setw(25) << left << "Kilowatt hours used" << ":" << kw << endl;
                cout << endl;
                cout << setw(25) << left << "Flat Service Charge" << 15.31 << endl;
                cout << setw(25) << left << "Kilowatt usage cost" << charges << endl;
                cout << setw(25) << left << "Total Bill" << total << endl;

                cout << endl;

                cout << "Do you want to enter another set? (Y/N)";
                cin >> again;
                again = toupper(again);

                while ((again != 'Y') && (again != 'N')){
                        cout << "ERROR: Enter Y/N: ";
                        cin >> again;
                        again = toupper(again);
                }
        } while(again == 'Y');
}


Please upvote, as i have given the exact answer as asked in question. Still in case of any issues in code, let me know in comments. Thanks!

Add a comment
Know the answer?
Add Answer to:
Write a program in c++ for An electric company came out with a residential rate schedule...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • The electric company charges according to the following rate schedule: 9 cents per kilowatt-hour (kwh) for...

    The electric company charges according to the following rate schedule: 9 cents per kilowatt-hour (kwh) for the first 300 kwh 8 cents per kwh for the next 300 kwh (up to 600 kwh) 6 cents per kwh for the next 400 kwh (up to 1000 kwh) 5 cents per kwh for all electricity used over 1000 kwh Write a program that would repeatedly read in a customer number (an integer) and the usage for that customer in kwh (an integer)....

  • USE C++ Hyde Park Electric Co. bills its customers on the basis of kilowatt hours (KWH)...

    USE C++ Hyde Park Electric Co. bills its customers on the basis of kilowatt hours (KWH) used, as follows: Kilowatt hours (KWH) used​​​Rate 1-100 7 cent per KWH 101-250 RM7.00 + 5 cents * KWH over 100 251-750 RM14.50 + 4 cents * KWH over 250 Over 750​​​​​RM34.50 + 3 cents * KWH over 750 The input will include each customer’s name, Account number and the number of kilowatt hours used (must be a positive value). The output should display...

  • 1. The electric utility rate for a facility during the months of May through October is...

    1. The electric utility rate for a facility during the months of May through October is 8.0 cents per kilowatt-hour for energy, $20.00 per kilowatt peak demand, and a $100.00 per month meter charge. During the August billing period the facility used 105,000 kw-hrs and set a peak demand of 1000 kw during the time between 4:45 p.m. and 5:00 p.m. in the afternoon on August 15. Calculate the August electric bill. (20%) med to be 100°F dh and 60°F...

  • A local electric company charges a base fee of $8 per month. They charge an additional...

    A local electric company charges a base fee of $8 per month. They charge an additional $0.1125 per kilowatt hour of electricity used. Use this information to answer the following. When you type in your answers, make sure to type the A, B, C, etc. so I know which answer goes to which part of the question. A. Write an equation to represent the total cost a customer will pay for their electric service. Let C represent the total monthly...

  • Hi everyone, I have a question which is really hard for me to figure it out...

    Hi everyone, I have a question which is really hard for me to figure it out i have to code this for c++. -When deciding about whether or not to install solar panels on your house, it becomes useful to project ahead as to how much you can expect pacific Gas & electric to raise its electric rates each year. - The lifetime of a solar installation is about 30 years, so you will want to know how much you'll...

  • INSTRUCTION AND PROBLEMS Write a Python program for each of the problems in this lab. Please...

    INSTRUCTION AND PROBLEMS Write a Python program for each of the problems in this lab. Please use PyCharm to type and test your programs. Submit the Python files to Blackboard for credit. In this lab, you should submit 4 Python files, one for each problem PROBLEM I Energy consumption is measured in units of kilowatt hours (kWh). The more kWh a household use in a month, the higher the energy bll. A power company charges customers $0.12 per kWh for...

  • Write a python program for the following problem? 100. Cost of Electricity formula The cost of...

    Write a python program for the following problem? 100. Cost of Electricity formula The cost of the electricity used by a device is given by the cost of electricity (in dollars) = wattage of device. hours used 1,000 · cost per kWh (in cents) where kWh is an abbreviation for "kilowatt hour.” The cost per kWh of electricity varies with locality. Suppose the current average cost of electricity for a residential customer in the United States is 11.76¢ per kWh....

  • The Metro Electric Company produces and distributes electricity to residential customers in New Brunswick.  The demand for...

    The Metro Electric Company produces and distributes electricity to residential customers in New Brunswick.  The demand for electricity is given by P = 0.04 – 0.01Q The resulting marginal revenue function is: MR = 0.04 – 0.02Q Metro’s marginal cost function is: MC = 0.005 + 0.0075Q where Q = millions of kilowatt hours and P = the dollars/kilowatt hour. If the mayor of New Brunswick wants to maximize surplus what price per month should she mandate that Metro charge? How...

  • JAVA *REFER TO THE PICTURES* Summary Write a program that will calculate the monthly electric charges...

    JAVA *REFER TO THE PICTURES* Summary Write a program that will calculate the monthly electric charges for a customer given a starting and ending readings from an electric meter. Charges will depend on the actual usage and the results will be displayed to the user Requirements From the user, get the month for the readings From the user, get the starting and ending reading values (in kWh) (integers) Standard rate is 42 cents per kWh Overage rate is 48 cents...

  • An Internet service provider offers four subscription packages to its customers, plus a discount for nonprofit...

    An Internet service provider offers four subscription packages to its customers, plus a discount for nonprofit organizations: Package A: 10 hours of access for $12.95 per month. Additional hours are $4.00 per hour. Package B: 20 hours of access for $14.95 per month. Additional hours are $2.00 per hour. Package C: 30 hours of access for $20 per month. Additional hours are $1.00 per hour. Package D: Unlimited access for $35.95 per month. A nonprofit organizations will get 20% discount...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT