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

You are to write a billing program for Mission Viejo Electric Company. Obtain th

ID: 3800663 • Letter: Y

Question

You are to write a billing program for Mission Viejo Electric Company.

Obtain the following integer values from the user: - the month
- the current meter reading
- the previous meter reading

Calculate an electric bill based on the following rate & consumption table:

Kilowatt Consumption Cost ----------------------------- ---------------------------------------------- 0 - 400 KWH a flat rate of $8.50

over 400 KWH $8.50 (base rate) +
7.525 cents for each KWH over 400 (May – Sept.) or

6.575 cents for each KWH over 400 (all other months)

If the user enters an invalid month, don’t ask the user to enter the meter readings. Your program should tell the user that the month was invalid and the program should not continue. If the month is valid, ask for the current and previous readings. The readings cannot be negative numbers. Also the current reading has to be the same or greater than the previous reading. If not, tell the user the readings are invalid and the program should not continue. If the month and readings are ok, calculate the amount due.

if(check if the month is bad) Display “invalid month”

else //the month is good {

//ask for meter readings

if(the readings are bad) display “bad readings”

else //the readings are good {

} }

return 0;

--Make sure you output the amount due to 2 decimal places.

Explanation / Answer

Answer:

#include <iostream>
#include <iomanip>

using namespace std;

int main() {
   int month, currentMeterReading, previousMeterReading;
   double cost;
  
   cout<<"Please enter the current month: ";
   cin>>month;
  
   //checking if month is invalid
   if(month < 1 || month > 12)
   {
        cout<<"Invalid Month";
        return -1;
   }
   else{
        cout<<"Please enter current meter reading: ";
        cin>>currentMeterReading;
  
        cout<<"Please enter previous meter reading: ";
        cin>>previousMeterReading;
  
        //checking if the readings are invalid
        if(currentMeterReading<0 || previousMeterReading<0 || currentMeterReading<previousMeterReading)
        {
            cout<<"Bad Readings";
            return -1;
        }
        else
        {
            //using flat rate if consumption is less than 400
            if(currentMeterReading <= 400)
            {
                cost = 8.50;
            }
            else
            {
                int noOfExtraKWH = currentMeterReading - 400;
                if(month<5 || month>9)
                {
                    cost = 8.50 + (noOfExtraKWH*0.06575);
                }
                else
                {
                    cost = 8.50 + (noOfExtraKWH*0.07525);
                }
            }
        }
      
     
        cout<<fixed<<"Current Month Bill: $"<<setprecision(2)<<cost<<endl;
   }
  
  
}

--------------------------------------------------------

OUTPUT:

Please enter the current month: 7
Please enter current meter reading: 900
Please enter previous meter reading: 450
Current Month Bill: $46.12

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