-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAppliance.java
More file actions
108 lines (103 loc) · 1.5 KB
/
Appliance.java
File metadata and controls
108 lines (103 loc) · 1.5 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
import java.util.*;
public class Appliance
{
String name;
int fans;
int tubelights;
int ACs;
int fridges;
int unitsConsumed;
boolean domestic,commercial;
double bill;
public Appliance()
{
this(" " ,0,0,0,0,0);
bill=(double)0.0;
}
public Appliance(String name,int fans,int tubelights,int ACs,int fridges,int units)
{
this.name=name;
this.fans=fans;
this.tubelights=tubelights;
this.ACs=ACs;
this.fridges=fridges;
this.unitsConsumed=units;
this.domestic=domestic;
this.commercial=commercial;
}
int getFans()
{
return fans;
}
int getTubelights()
{
return tubelights;
}
int getAC()
{
return ACs;
}
int getFridges()
{
return fridges;
}
String getName()
{
return name;
}
void calculate()
{
bill=(double)0.0;
int units=unitsConsumed;
//double units=(double)2000;
if(units>500)
{
bill=(double)50;
}
else if(units<=500)
{
bill=(double)30;
}
else if(units<=200)
{
bill=(double)20;
}
else if(units<=100)
{
bill=(double)0;
}
for(;units>0;)
{
if((units>0) && (units <=100))
{
bill+=(double)(100*1.50);
units-=100;
}
else if((units>100)&&(units<=200))
{
bill+=(double)(100*3.50);
units-=100;
}
else if((units>200)&&(units<=500))
{
bill+=(double)(300*4.60);
units-=300;
}
else if(units>500)
{
bill+=(double)(500*6.60);
units-=500;;
}
}
bill-=(double)150;
}
int getUnits()
{
return unitsConsumed;
}
double getBill()
{
//System.out.println
return bill;
}
}