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)
#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;
}
Comments
Leave a comment