Answer to Question #217505 in C for Prasanna

Question #217505

An electricity board charges the following rates for the use of electricity: Number of Units Cost per Unit For the first 200 units Paise: 0.80per unit For the next 100 units Paise: 0.90per unit For the next and above 300 units Rupee: 1.00per unit All users are charged a minimum of Rs. 100 as meter charge. If the total amount is more than Rs.400, then an additional surcharge of 15% of total amount is charged. Read the names of users and number of units consumed and print out the charges with names.


Runtime Input :

100

500

Output :

Starting Reading: 100

Last Reading: 500

Unit Consumed: 400

Total Cost: 517.50


1
Expert's answer
2021-07-15T07:11:49-0400
#include <stdio.h>


int main()
{
char name[100];
float unit_used, amount;
printf("Enter the user name:  ");
scanf("%s", &name);




printf("Enter unit Consumed:   ");


scanf("%f",&unit_used);


if(unit_used<125)


amount=100;


else if(unit_used<=200)


amount=unit_used*.80;


else if(unit_used<=300)


amount=(unit_used-200)*0.90+160;


else


if(unit_used>300)


amount=(unit_used-300)*1+250;


if(amount>=400)


amount=amount+amount*0.15;
printf("Name:    %s\n", name );
printf("Charge:   %5.2f",amount);


}

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