-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathRoom.java
More file actions
57 lines (55 loc) · 1.42 KB
/
Room.java
File metadata and controls
57 lines (55 loc) · 1.42 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
import java.util.Scanner;
public class Room
{
boolean AC_ON, HOME_THEATRE_ON, FAN_ON, LIGHT_ON;
Room(boolean AC_ON, boolean HOME_THEATRE_ON, boolean FAN_ON, boolean LIGHT_ON)
{
this.AC_ON=AC_ON;
this.HOME_THEATRE_ON=HOME_THEATRE_ON;
this.FAN_ON=FAN_ON;
this.LIGHT_ON=LIGHT_ON;
}
public void Display()
{
int sum=0;
if(AC_ON==true)
{
sum=sum+1200;
}
if(HOME_THEATRE_ON==true)
{
sum=sum+600;
}
if(FAN_ON==true)
{
sum=sum+400;
}
if(LIGHT_ON==true)
{
sum=sum+100;
}
if(sum>2000)
{
System.out.println("Overloaded");
}
else
{
System.out.println( "Amount of Electricity Consumed : "+sum);
}
}
public static void main(String[] args)
{
System.out.println("Enter 'true' for switch on otherwise 'false'");
Scanner sc=new Scanner(System.in);
System.out.println("Enter Switch AC");
boolean a=sc.nextBoolean();
System.out.println("Enter Switch Home theatre");
boolean b=sc.nextBoolean();
System.out.println("Enter Switch Fan");
boolean c=sc.nextBoolean();
System.out.println("Enter Switch Light ");
boolean d=sc.nextBoolean();
Room obj=new Room(a,b,c,d);
obj.Display();
}
}