-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathElectric.java
35 lines (31 loc) · 886 Bytes
/
Electric.java
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
import java.util.*;
class Electric
{
public static void main(String args[])
{
double u,ec,fc,st,gst,net;
Scanner sc = new Scanner(System.in);
System.out.print("Enter the Units comsumed: ");
u=sc.nextDouble();
fc=(u<300)?100:150;
if(u<=100)
ec=u*5;
else if(u<=300)
ec=500+(7*(u-100));
else if(u<=500)
ec=500+1400+(10*(u-300));
else
ec=500+1400+2000+(15*(u-500));
st=fc+ec;
gst=0.12*st;
net=st+gst;
System.out.println("*******************************************************************");
System.out.println("Unit Consumed: "+u);
System.out.println("Electricity Charge: "+ec);
System.out.println("Fixed Charge: "+fc);
System.out.println("Sub-Total: "+st);
System.out.println("GST: "+gst);
System.out.println("Net Payment: "+net);
System.out.println("*******************************************************************");
}
}