-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathlock.cpp
More file actions
32 lines (25 loc) · 671 Bytes
/
lock.cpp
File metadata and controls
32 lines (25 loc) · 671 Bytes
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
#include <iostream>
int main() {
int defpin=1541;
int pin;
int tries = 3;
std::cout << "Lock Room\n"; //Message
while (tries != 0 ) { //initialize loop
std::cout << "Enter your PIN: "; //input by user
std::cin >> pin;
if (pin == defpin) { //Success condition
std::cout << "PIN accepted!\n";
std::cout << "You now have access.\n";
break;
}
else { //failcase
if (tries == 1){
std::cout << "User Locked for 24 hours\n";
}
else {
std::cout << "Wrong Pin. Try Again\n";
}
}
tries--;
}
}