An electric supply company is charging the electricity consumption, as follows :
ID: 1716101 • Letter: A
Question
An electric supply company is charging the electricity consumption, as follows : For the first 200 units, 2.5 AED per unit 2. For the next 300 units, 4.5 AED per unit 3. Over500units,5.5AEDperunit In addition, to encourage low electricity consumption, the company offers 10% discount if the consumption is less than 180 units, and 5% surcharge is added to the cost if the consumption is greater than 600 units. Write a program ( use c++ ) that reads the electricity consumption in units and displays The consumer consumption cost
Explanation / Answer
To solve this exercise, first we need to list the conditions that we have:
1. per 200units the cost would be 2.5 per unit
2. per 300 units the cost would be 4.5 per unit
3. more than 500 units the cost would be 5.5 per unit
4. less than 180 units there will be a discount of -10%
5. more than 600 units will exist +5% over the total.
for conditions 4 and 5 we can handle them using totals amounts, that is:
in the case of the condition number 4: if we consumed 180 units or less the cost is still 2.5 per unit (see condition number 1), then we will apply a discount when the total amount be less or equal than 450.
in the case of the condition number 5: if we consumed 600 units or more the cost is still 5.5 per unit (see condition number 3), then, when the total amount be equal or more than 3300 we have to add +5%.
Finally, our program in c++ would be:
#include <iostream.h>
#include <conio.h>
void main()
{
float total;
char user[40];
float units;
float perc=0;
float final_cost;
clrscr();
cout<<" Electricity Board Charges ";
cout<<" Enter user`s name and lastname :-";
cin>>user;
cout<<" Enter the total of Units Consumed:-";
cin>>units;
if(units<=200)
total=unit*2.5;
elseif(unit<=300)
total=unit*4.5;
else
total=unit*5.5;
if(total<=450)
perc=total*0.1;
final_cost = total-perc;
elseif(total>=3300)
perc=total*0.05;
final_cost = total+perc;
cout<<" The final amount is: "<<final_cost;
getch();
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.