Answer to Question #217512 in C for Vishnukumar

Question #217512

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 t he 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 to tal amount is charged. Read the names of users and number of units consumed and print out t he charges with names.


1
Expert's answer
2021-07-15T07:11:52-0400
#include <stdio.h>
int main()
{
    int unit;
    float amount, totalAmount, surCharge;


    
    printf("Enter the number of units used: ");
    scanf("%d", &unit);




    
    if(unit <= 200)
    {
        amount = unit * 0.80;
    }
    else if(unit <= 300)
    {
        amount = 100 + ((unit-200) * 0.90);
    }
    else if(unit >= 350)
    {
       amount =  110 + ((unit-150) * 1.00);
    }
    
    if(amount>400){
    	surCharge = amount * 0.15;
	}
    
    totalAmount = amount + 	surCharge;


    printf("Bill = Rs. %.2f", totalAmount);


    return 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
APPROVED BY CLIENTS