Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2017
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.79 KB | None | 0 0
  1. import java.util.Scanner;
  2. public class Login2
  3. {
  4. static Account[] AccountData = new Account[33];
  5. public static void main(String[] args)
  6. {
  7. int INVALID = 0;
  8. boolean exitMain = false;
  9. Scanner in = new Scanner(System.in);
  10. AccountData[0] = new Account("kyle", 123, true);
  11. while (exitMain == false)
  12. {
  13. int accountNum = 0;
  14. if (INVALID % 2 == 0)
  15. {
  16. System.out.println("Create, Login, or Exit?");
  17. }
  18. INVALID++;
  19. String command = in.nextLine();
  20. command = command.toLowerCase();
  21. if (command.equals("create"))
  22. {
  23. boolean exitCreate = false;
  24. while (exitCreate == false)
  25. {
  26. System.out.println("Enter a username: ");
  27. String inputUser = in.nextLine();
  28. System.out.println("Enter a password PIN: ");
  29. int inputPass = in.nextInt();
  30.  
  31. if (accountNum < 33)
  32. {
  33. AccountData[accountNum] = new Account(inputUser, inputPass, false);
  34. accountNum++;
  35. exitCreate = true;
  36. }
  37. else
  38. {
  39. System.out.println("Max Account Capacity");
  40. exitCreate = true;
  41. }
  42. }
  43. }
  44. else if (command.equals("login"))
  45. {
  46. System.out.println("Enter your username: ");
  47. String username = in.nextLine();
  48. System.out.println("Enter your password PIN: ");
  49. int password = in.nextInt();
  50. int search = 0;
  51. boolean exitLogin = false;
  52. while (exitLogin == false && search <= accountNum)
  53. {
  54. if(username.equals(AccountData[search].username) && password == AccountData[search].password && AccountData[search].admin == true)
  55. {
  56. System.out.println("Create Admin (create), Delete Account (delete), or Print?");
  57. while(exitLogin == false && search <= accountNum)
  58. {
  59.  
  60. String option = in.nextLine();
  61. if(option.equals("create"))
  62. {
  63. System.out.println("Enter a username: ");
  64. String inputUser1 = in.nextLine();
  65. System.out.println("Enter a password PIN: ");
  66. int inputPass1 = in.nextInt();
  67.  
  68. if (accountNum < 33)
  69. {
  70. AccountData[accountNum] = new Account(inputUser1, inputPass1, true);
  71. accountNum++;
  72. exitLogin = true;
  73. }
  74. else
  75. {
  76. System.out.println("Max Account Capacity");
  77. exitLogin = true;
  78. }
  79. }
  80. else if(option.equals("delete"))
  81. {
  82. System.out.println("Type the number for the account you want to remove:");
  83. int remove = in.nextInt();
  84. AccountData[remove] = new Account("", 0 , false);
  85. System.out.println("Successfully Removed.");
  86. exitLogin = true;
  87. }
  88. else if(option.equals("print"))
  89. {
  90. System.out.println("Usernames:" + AccountData[search].username);
  91. System.out.println("Passcodes:" + AccountData[search].password);
  92. exitLogin = true;
  93.  
  94. }
  95. }
  96. }
  97. else if (username.equals(AccountData[search].username) && (password == AccountData[search].password && AccountData[search].admin == false))
  98. {
  99. System.out.println("Welcome!");
  100. exitLogin = true;
  101. exitMain = true;
  102. }
  103.  
  104. search++;
  105. }
  106. }
  107. else if (command.equals("exit"))
  108. {
  109. System.out.println("Program will now exit.");
  110. exitMain = true;
  111. }
  112. }
  113. in.close();
  114. }
  115. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement