Answer to Question #281068 in C++ for thurga

Question #281068

Calculate the unit of electricity consumed by a customer with the conditions stated below and print it a bill form. 

 

1. For 1st 100 units @ RM 1/unit. 

2. For next 100 units @ RM 2/unit. 

3. For next 100 units @ RM 3/unit. 

4. For next 200 units @ RM 4 /unit. 

5. For next units @ RM 5/unit. 

6. Tax to be added in final amount @ 10%. 

7. Meter charge RM 50. extra. Construct the necessary script to solve the given problem. 

Construct the necessary script to solve the given problem – Print The bill 


1
Expert's answer
2021-12-20T09:53:37-0500
#include<iostream>

using namespace std;

int main()
{
	int units;
	double resBill;
	do
	{
		cout << "\nPlease, enter a consumed units of electricity: ";
		cin >> units;
		if (units >=500)
		{
			resBill = 100 + 100 * 2 + 100 * 3 + 200 * 4 + (units - 500) * 5;
		}
		else if (units < 500 && units>300)
		{
			resBill = 100 + 100 * 2 + 100 * 3 + (units - 300) * 4;
		}
		else if (units <= 300 && units > 200)
		{
			resBill = 100 + 100 * 2 + (units - 200) * 3;
		}
		else if (units <= 200 && units > 100)
		{
			resBill = 100 + (units - 100) * 2;
		}
		else
		{
			resBill = units;
		}
		resBill = resBill + resBill*0.1+50;
		cout << "Your bill is " << resBill << " RM";
	} while (units >= 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