-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSmartHomeSystem.cpp
More file actions
56 lines (51 loc) · 1.31 KB
/
SmartHomeSystem.cpp
File metadata and controls
56 lines (51 loc) · 1.31 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
#include <iostream>
#include <string>
using namespace std;
int main () {
int select1, fanstatus=0, pin, userpin=1111; //1-on 2-off
while (true) {
cout << "*********Smart Home Control System*********" << endl;
int i = 0;
while (pin!=userpin) {
cout << "Enter your pin.";
cin >> pin;
if (pin!=userpin) {
i++;
if (i<3) {
cout << "Wrong Pin Entered. Please Try Again." << endl;
} else {
cout << "Wrong Pin entered too many times. Try again after a while." << endl;
return 0;
}
}
}
cout << "Select the appropriate option." << endl;
cout << "1. Fan." << endl;
cin >> select1;
switch (select1) {
case 1:
if (fanstatus == 1) {
cout << "Press 0 to turn off the Fan." << endl;
cin >> fanstatus;
if (fanstatus == 0) {
cout << "Fan turn off successfully" << endl;
} else {
cout << "Invalid input" << endl;
}
} else {
cout << "Press 1 to turn on the Fan." << endl;
cin >> fanstatus;
if (fanstatus == 1) {
cout << "Fan turn on successfully" << endl;
} else {
cout << "Invalid input" << endl;
}
}
break;
case 2:
cout << "Thank you for using ALHABIB ATM." << endl;
return 0;
} // switch ends
} // while ends
return 0;
}