Advertisement
Guest User

Untitled

a guest
Jun 26th, 2017
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. // APCS1 Lab Test 2
  2. //
  3. // Prog06.java
  4. //
  5. // PIN Protection
  6. //
  7. // Points: 3
  8. //
  9. ////////////////////////////////////////////////////////////////////////////////
  10. // Write a program that will use the Scanner class to input a PIN number.
  11. // The program needs to keep asking the user for the PIN until they
  12. // enter the proper PIN number of 4567.
  13. //
  14. // When completed, the output of the program should look like this:
  15. //
  16. // Enter PIN: 1234
  17. // Incorrect PIN. Try again.
  18. //
  19. // Enter PIN: 2345
  20. // Incorrect PIN. Try again.
  21. //
  22. // Enter PIN: 3456
  23. // Incorrect PIN. Try again.
  24. //
  25. // Enter PIN 4567
  26. // Please select from the following options.
  27. //
  28. //
  29. ////////////////////////////////////////////////////////////////////////////////
  30. // NOTE: Make sure you execute the program and enter all 4 inputs BEFORE you
  31. // raise your hand!
  32.  
  33.  
  34.  
  35.  
  36. import java.util.Scanner;
  37.  
  38. public class Prog06
  39. {
  40. public static void main (String args[])
  41. {
  42. Scanner input = new Scanner(System.in);
  43. int guess = 0;
  44. while (guess != 4567)
  45. {
  46. System.out.print("Enter your PIN ==>> ");
  47. guess = input.nextInt();
  48. if (guess == 4567)
  49. System.out.println("Access Granted.");
  50. else
  51. System.out.println("Incorrect PIN. Try again");
  52. System.out.println();
  53. }
  54.  
  55. }
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement