-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpin_switch_case
More file actions
36 lines (34 loc) · 959 Bytes
/
pin_switch_case
File metadata and controls
36 lines (34 loc) · 959 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
33
34
35
36
#include <iostream>
using namespace std;
/*Since this app is asking you to enter all of
the inputs at once, do NOT forget to separate
the different inputs with new lines, else the
program will use the same input every time.*/
int main(){
int a,b,c,d,e;
for (int x=3; x > 0; x--)
{
cout <<"Please, insert your PIN\n\n";
cin >>a>>b>>c>>d>>e;
if (a==1&&b==2&&c==3&&d==4&&e==5){
cout <<"Access granted!\n";
break;
}
else {
cout <<"Wrong PIN!\n";
switch (x){
case 3:
cout <<"Two more tries left!\n\n";
break;
case 2:
cout <<"One more try left!\n\n";
break;
case 1:
cout <<"No more tries left!\n";
cout <<"Access denied!\n";
break;
}
}
}
return 0;
}