Answer to Question #132330 in C for K. Arun sriram

Question #132330
WAP to calculate an electricity bill using decision making. As every house has got electricity now a days, the chief in electricity board is in pressure of generating automated bills. So he approached your team to work for him. He explains to you all the cases to be considered to calculate the accurate bill.
For instance,
I. Bill paid within 15days of generation.
II. If reading is less than or equal to 200 units then each unit is charged Rs. 2.
III. If reading is more than 200 units but less than or equal to 400units then for first 200 units charges will be Rs.2 and other units are charged at Rs. 4
IV. If reading is more than 400 units then all the units will be charged Rs. 4.
V. Bill paid after 15days of generation: A surcharge of 10% on your bill amount has to be paid.
Now considering these cases help the chief in automating the billing system.
1
Expert's answer
2020-09-10T06:03:00-0400

let x be the number of units consumed

and y be the number of days

and p be the electricity bill

Required codes are-


#include<stdio.h>

main()

{int x,y,p;

 printf("please enter the number of consumed units and number of days consumed");

 scanf("%d%d",&x,&y);

 if(x"\\le" 200)

 {p=2"\\times" x;

 }

 if(x"\\ge" 200&&x"\\le" 400)

 {p=200"\\times" 2+(x-200)"\\times" 4;

 }

 if(x"\\ge" 400)

 {p=4"\\times" x;

 }

 if(y"\\le" 15)

 printf("price is %d",p);

 else

 {"p=p+\\frac{p}{10};" ;

 printf("price is %d",p);

}

}


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