-
Notifications
You must be signed in to change notification settings - Fork 769
/
Electric Bill
81 lines (72 loc) · 2.1 KB
/
Electric Bill
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#include <stdio.h>
int main()
{
int Units;
float Amount, Sur_Charge, Total_Amount;
printf("\n Please Enter the Units that you Consumed : ");
scanf("%d", &Units);
if (Units < 50)
{
Amount = Units * 2.60;
Sur_Charge = 25;
}
else if (Units <= 100)
{
// First Fifty Units charge is 130 (50 * 2.60)
// Next, we are removing those 50 units from total units
Amount = 130 + ((Units - 50 ) * 3.25);
Sur_Charge = 35;
}
else if (Units <= 200)
{
// First Fifty Units charge is 130, and 50 - 100 is 162.50 (50 * 3.25)
// Next, we are removing those 100 units from total units
Amount = 130 + 162.50 + ((Units - 100 ) * 5.26);
Sur_Charge = 45;
}
else
{
// First Fifty Units 130, 50 - 100 is 162.50, and 100 - 200 is 526 (100 * 5.65)
// Next, we are removing those 200 units from total units
Amount = 130 + 162.50 + 526 + ((Units - 200 ) * 7.75);
Sur_Charge = 55;
}
Total_Amount = Amount + Sur_Charge;
printf("\n Electricity Bill = %.2f", Total_Amount);
return 0;
}
{
int Units;
float Amount, Sur_Charge, Total_Amount;
printf("\n Please Enter the Units that you Consumed : ");
scanf("%d", &Units);
if (Units < 50)
{
Amount = Units * 2.60;
Sur_Charge = 25;
}
else if (Units <= 100)
{
// First Fifty Units charge is 130 (50 * 2.60)
// Next, we are removing those 50 units from total units
Amount = 130 + ((Units - 50 ) * 3.25);
Sur_Charge = 35;
}
else if (Units <= 200)
{
// First Fifty Units charge is 130, and 50 - 100 is 162.50 (50 * 3.25)
// Next, we are removing those 100 units from total units
Amount = 130 + 162.50 + ((Units - 100 ) * 5.26);
Sur_Charge = 45;
}
else
{
// First Fifty Units 130, 50 - 100 is 162.50, and 100 - 200 is 526 (100 * 5.65)
// Next, we are removing those 200 units from total units
Amount = 130 + 162.50 + 526 + ((Units - 200 ) * 7.75);
Sur_Charge = 55;
}
Total_Amount = Amount + Sur_Charge;
printf("\n Electricity Bill = %.2f", Total_Amount);
return 0;
}