-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathScenario2.java
More file actions
33 lines (30 loc) · 776 Bytes
/
Copy pathScenario2.java
File metadata and controls
33 lines (30 loc) · 776 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
package PackageIntro;
import java.util.Scanner;
public class Scenario2 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int pin = 333;
int attempt = 0;
boolean check = true;
do {
for (int i = 1; i <=3; i++) {
System.out.println("Please enter the PIN:");
attempt = sc.nextInt();
if (attempt == pin) {
check = false;
}
else if (i == 3) {
System.out.println("You have already tried 3 attempts, you will be locked out.");
System. exit(0);
}
else {
System.out.println("Incorrect PIN");
check = true;
}
}
}
while (check);
System.out.println("You have successfully entered the PIN, welcome!");
// TODO Auto-generated method stub
}
}