Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class pin {
- public static void main(String[] args) {
- //Develop a java program to validate bank PIN of a customer. Use a while loop to repeat code until a valid PIN
- //is entered.
- /*
- *Declare a valid integer PIN
- * Prompt the user to enter the PIN.
- *In a while loop, perform the following steps:
- * Compare the user-entered PIN with the already declared PIN
- * If the entered PIN is not the same, prompt the user to enter the PIN again
- * Repeat the loop until the correct PIN is entered.
- *Print a message confirming that the correct PIN has been entered and that the user now has access to their account.
- */
- Scanner input = new Scanner (System.in);
- int pin = 1279, user_pin;
- System.out.println("Pin Number: ");
- user_pin = input.nextInt();
- while(user_pin != 1279) {
- if(user_pin != pin) {
- System.out.println("Incorrect pin. Enter pin again.");
- //System.out.println("Pin Number: ");
- //user_pin = input.nextInt();
- }
- if(user_pin == pin) {
- System.out.println("Correct pin.");
- }
- System.out.println("Pin Number: ");
- user_pin = input.nextInt();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement