Answer to Question #179262 in C++ for SWB

Question #179262

You are required to write an C++ program that calculates the electricity bill of the customer during COVID 19 pandemic. The C++ program should take input from the user the followings

1. the number of units consumed

2. the billing month 

The bill is calculated by the followings

If the number of units consumed are between 1 to 100 then the per unit price is Rs 100. If the number of units consumed is greater than 100 but less than 150, then the per unit price is Rs 200. If the number of units consumed is greater than 200 then the per unit price is 250 and an additional 5% tax on the total bill is incurred on the customer (Hint use nesting to solve this) 



1
Expert's answer
2021-04-07T17:41:09-0400
#include <iostream>
#include <iomanip>
using namespace std;
   
int main() {
       int  month = 0;
    float number = 0, total;
    
    while(number<=0){
        cout << "Enter the number of units consumed: ";
        cin >> number;
    }
    while(month<=0 || month>12){
        cout << "Enter the billing month (1 - 12): " ;
        cin >> month;
    }
    if (number <= 100 && number>=1)  
        total = number*100;
    else if (number > 100 && number<150)
        total = number*200;
    else if(number>200)
        total = number*250 + number*250*0.05;
    else
        total = number*250;
    cout<<"--------------------------------------------------------------------"<<endl;
    cout << "The electricity bill of the customer during COVID 19 pandemic: Rs. "
    <<fixed<<setprecision(2)<<total<<endl;
     
    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS