Question
When you use an automated teller machine (ATM) with your bank card, you need to use a personal identification number (PIN) to access your account.
When you use an automated teller machine (ATM) with your bank card, you need to use a personal identification number (PIN) to access your account. If a user fails more than three times when entering the PIN, the machine will block the card. Assume that the users PIN is 1234 and write a program that asks the user for the PIN no more than three times, and does the following:
If the user enters the right number, print a message saying, Your PIN is correct, and end the program.
If the user enters a wrong number, print a message saying, Your PIN is incorrect and, if you have asked for the PIN less than three times, ask for it again.
If the user enters a wrong number three times, print a message saying Your bank card is blocked and end the program.
import java.util.Scanner;
/**
*Code for P5.12
*author
*/
public class ATMValidator
{
public static void main(String[] args)
{
final String MY_PIN = "1234";
Scanner in = new Scanner(System.in);
System.out.print("Enter your PIN: ");
String pin = in.next();
// Your work goes here
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started