-
Notifications
You must be signed in to change notification settings - Fork 0
/
Light On-Off
41 lines (34 loc) · 889 Bytes
/
Light On-Off
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
# Saon Sikder
# Dhaka, Bangladesh
import java.util.Scanner;
public class LightOnOff {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
String check;
boolean light_on = false;
while (true) {
System.out.print("-- ");
check = scanner.next();
if (check.equalsIgnoreCase("On")) {
if (light_on) {
System.out.println("Light is already in On Mode");
} else {
System.out.println("Light On, Done");
light_on = true;
}
} else if (check.equalsIgnoreCase("Off")) {
if (!light_on) {
System.out.println("Light is already in OFF Mode");
} else {
System.out.println("Light Off, Done");
light_on = false;
}
} else if (check.equalsIgnoreCase("quit")) {
System.out.println("Thanks for Programming");
break;
} else {
System.out.println("Invalid Command.....");
}
}
}
}