-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.cpp
More file actions
65 lines (50 loc) · 1.61 KB
/
test.cpp
File metadata and controls
65 lines (50 loc) · 1.61 KB
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
/*
https://www.w3resource.com/c-programming-exercises/conditional-statement/index.php
19. Write a program in C to calculate and print the electricity bill of a given customer. The customer ID, name, and unit consumed by the user should be captured from the keyboard to display the total amount to be paid to the customer.
The charge are as follow :
Unit Charge/unit
upto 199 @1.20
200 and above but less than 400 @1.50
400 and above but less than 600 @1.80
600 and above @2.00
If bill exceeds Rs. 400 then a surcharge of 15% will be charged and the minimum bill should be of Rs. 100/-
*/
#include<bits/stdc++.h>
using namespace std;
int main()
{
int units;
cout<<"Enter total units"<<endl;
cin>>units;
bool isSurchargeApplicable = false;
float cost = 0;
if(units>599) {
isSurchargeApplicable = true;
int spentUnits = units - 600 + 1;
cost += (spentUnits) * 2.00;
units = units - spentUnits;
cout<<"Greater than 599"<<endl;
}
if(units>399) {
isSurchargeApplicable = true;
int spentUnits = units - 400 + 1;
cost += (spentUnits) * 1.80;
units = units - spentUnits;
cout<<"Greater than 399"<<endl;
}
if(units>199) {
int spentUnits = units - 200 + 1;
cost += (spentUnits) * 1.50;
units = units - spentUnits;
cout<<"Greater than 199"<<endl;
}
if(units<200) {
int spentUnits = units;
cost += (spentUnits) * 1.20;
units = units - spentUnits;
cout<<"Less than 200"<<endl;
}
cost += ((15.0*cost)/100);
cout<<cost<<endl;
return 0;
}