Answer to Question #98362 in C++ for matimu

Question #98362
An electricity board charges the following rates to domestic users to discourage large consumption of energy:
- For the first 100 units−50 P per unit - Beyond 300 units − 60 P per unit

If the total cost is more than Rs.250.00 then an additional surcharge of 15% is added on the difference. Define a class Electricity in which the function Bill computes the cost. Define a derived class More Electricity and override Bill to add the surcharge.
1
Expert's answer
2019-11-11T08:29:52-0500
class Electricity
{
public:
	double Bill(double unit)
	{
		double tc;
		if (unit < 100)
			tc = unit * 0.5;
		if (unit > 300)
			tc = unit * 0.6;
		double surchase = 0;
		if (tc > 250)
			surchase = tc * 0.15;
		double total_cost;
		total_cost = 250 + surchase + tc;
		return total_cost;
	}
};
class MoreElectricity : public Electricity
{
public:
	double Bill(double unit, double add)
	{
		Electricity b;
		double price = b.Bill(unit);
		double total_cost = price + add;
		return total_cost;
	}
};

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