Answer to Question #262891 in C for Isa

Question #262891



Using loops and condition statements together, Write a program that calculate the cost of energy for energy units restricted between 0 to 500 kWh for an amount less than $6 000.00 for any Zimbabwean resident customer and any amount and unlimited number of units for a foreign resident customer buying from outside Zimbabwe at a rate of $90.00 to one USD. The tariffs are as follows:








• 0 to 50 kWh cost $2.25








• Above 50 kWh to 100 kWh cost $4.51 / kWh








• Above 100kWh to 200 kWh cost $7.89 / kWh








• Above 200kWh to 300 kWh cost $11.25 / kWh








• Above 300kWh to 400 kWh cost $12.94 / kWh








• Above 400 kWh cost $13.50 / kWh

1
Expert's answer
2021-11-08T17:33:47-0500


#include <stdio.h>


int main()
{
    int n;
    printf("Enter the energy in watts: ");
    scanf("%d",&n);
    if(n>=0&& n<=50){
        double price=n*2.25;
        printf("Total price is: %.2f",price);
    }
    else if(n>50&& n<=100){
        double price=n*4.51;
        printf("Total price is: %.2f",price);
    }
    else if(n>100&& n<=200){
        double price=n*7.89;
        printf("Total price is: %.2f",price);
    }
    else if(n>200&& n<=300){
        double price=n*11.25;
        printf("Total price is: %f",price);
    }
    else if(n>300&& n<=400){
        double price=n*12.94;
        printf("Total price is: %.2f",price);
    }
    else if(n>400){
        double price=n*13.50;
        printf("Total price is:%.2f",price);
    }
}

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