Answer to Question #308107 in C for ram

Question #308107

You are given an electricity project for the calculation of amount for the consumed electricity units for every one month.

1) For the electricity units (0-200) is 50 paisa per units.

2) For the electricity units (201-400) is 65 paisa per unit. For the first 0-200 consumed units charge is 100 rupees, if the consumer consumed greater than 200 and less than or equal to 400 unit, then for each unit charge is 65 paisa.

3)For the electricity units (401-600) is 80 paisa per unit. For the first 0-400 consumed units charge is 230 rupees, if the consumer consumed greater than 400 unit and less than or equal to 600, then for each unit charge is 80 paisa.

4)For the electricity units above 600, the price for each unit is 80 paisa. For the first 0-600 units charge is 390 rupees, if the consumer consumed greater than 600 unit, then for each unit charge 1.50 paisa.

Case= Test 1

input=

123

100

output=

Electricity Amount to be paid is:50.00

Case= Test 2

input=

124

300

output=

Electricity Amount to be paid is:165.00


1
Expert's answer
2022-03-09T06:38:19-0500
#include <stdio.h>

int main()
{
    int month;
    float el_units, sum;
    sum = 0;
    printf("Enter month: ");
    scanf("%d", &month);
    printf("Enter consumed electricity units: ");
    scanf("%f", &el_units);
    if (el_units <= 200)
        sum = (el_units * 0.50);
    else if ((el_units >= 201) & (el_units <= 400))
        sum = (100 + (el_units - 200) * 0.65);
    else if ((el_units >= 401) & (el_units <= 600))
        sum =(230 + (el_units - 400) * 80);
    else if ((el_units >= 401) & (el_units <= 600))
        sum =(390 + (el_units - 600) * 1.5);
    printf("\n\nElectricity Amount to be paid is: %.2f\n", sum);
}   

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