Answer:
is this you looking for?
import java.util.Scanner;
public class PIN {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int pin = 1234;
int userPIN = 0;
int attempts = 0;
while (userPIN != pin && attempts < 3) {
System.out.print("Enter your PIN: ");
userPIN = input.nextInt();
if (userPIN != pin) {
System.out.println("Invalid PIN, try again");
attempts++;
}
}
if (attempts == 3) {
System.out.println("Attempt limit exceeded. Account has been locked");
} else {
System.out.println("Access granted");
}
}
}