Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // APCS1 Lab Test 2
- //
- // Prog06.java
- //
- // PIN Protection
- //
- // Points: 3
- //
- ////////////////////////////////////////////////////////////////////////////////
- // Write a program that will use the Scanner class to input a PIN number.
- // The program needs to keep asking the user for the PIN until they
- // enter the proper PIN number of 4567.
- //
- // When completed, the output of the program should look like this:
- //
- // Enter PIN: 1234
- // Incorrect PIN. Try again.
- //
- // Enter PIN: 2345
- // Incorrect PIN. Try again.
- //
- // Enter PIN: 3456
- // Incorrect PIN. Try again.
- //
- // Enter PIN 4567
- // Please select from the following options.
- //
- //
- ////////////////////////////////////////////////////////////////////////////////
- // NOTE: Make sure you execute the program and enter all 4 inputs BEFORE you
- // raise your hand!
- import java.util.Scanner;
- public class Prog06
- {
- public static void main (String args[])
- {
- Scanner input = new Scanner(System.in);
- int guess = 0;
- while (guess != 4567)
- {
- System.out.print("Enter your PIN ==>> ");
- guess = input.nextInt();
- if (guess == 4567)
- System.out.println("Access Granted.");
- else
- System.out.println("Incorrect PIN. Try again");
- System.out.println();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement