Use loops and conditionals together to build a secure PIN entry system. The user gets 3 attempts to enter the correct PIN before being locked out.
YOUR TASK
Create a program that:
Stores a correct PIN (hardcode it as "1234")
Gives the user 3 attempts using a loop
Prints Wrong PIN. Try again. on bad input
Prints Access Granted! when correct
Prints Account Locked. after 3 failed attempts
Need a hint?
Step-by-step:
1. Set string correctPin = "1234";
2. Use for (int i = 0; i < 3; i++)
3. Inside: read input, compare with ==, use break on success
4. After the loop, check if still not matched → print "Account Locked."
Example (input: 0000 then 1234):
Enter PIN: 0000
Wrong PIN. Try again.
Enter PIN: 1234
Access Granted!
Code Editor Ready
Output
Console
Console initialized...
Ready for Project 4: PIN Login System
> Test input: first wrong, then correct (0000 then 1234)
> When it passes, the Complete button will activate!