Advertisement
Guest User

Untitled

a guest
Jul 11th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.36 KB | None | 0 0
  1. /*
  2. * To change this template, choose Tools | Templates
  3. * and open the template in the editor.
  4. */
  5. package javaapplication1;
  6.  
  7. import java.util.Scanner;
  8.  
  9. /**
  10. *
  11. * @author 1LUNGUMAT
  12. */
  13. public class Summative2 {
  14. //Creating the scanner
  15.  
  16. public static Scanner inputKeyboard = new Scanner(System.in);
  17. public static String[] nameDatabase = {"Rajat", "raZtek", "Matt", "Alan", "TravisLEE"};
  18. public static String[] passwordDatabase = {"Lol", "razersucksass", "roflmao", "holy", "chinawillrule"};
  19. public static String usernameEntered;
  20. public static String passwordEntered;
  21. public static boolean correct;
  22. public static int selection;
  23. public static int goBack;
  24. public static int selectionMainMenu2;
  25. public static boolean loggedin;
  26.  
  27. public static void main(String[] args) {
  28. mainMenu();
  29. }
  30.  
  31. public static void viewHighScores() {
  32. System.out.println("Works");
  33. }
  34.  
  35. public static void login() {
  36. System.out.println("Enter Username: ");
  37. usernameEntered = inputKeyboard.next();
  38. System.out.println("Enter Password: ");
  39. passwordEntered = inputKeyboard.next();
  40. for (int index = 0; index < nameDatabase.length; index++) {
  41. if (usernameEntered.equals(nameDatabase[index]) && passwordEntered.equals(passwordDatabase[index])) {
  42. mainMenu2();
  43. } else {
  44. correct = false;
  45. }
  46. }
  47. correct = false;
  48. if (correct == false) {
  49. System.out.println("Wrong Username or Password");
  50. System.out.println("1. Try Again");
  51. System.out.println("2. Exit Math To The Max");
  52. System.out.println("Your choice: ");
  53. goBack = inputKeyboard.nextInt();
  54. if (goBack < 1 || goBack > 2) {
  55. System.out.println("Please enter 1 to Try Again and 2 to Exit.");
  56. }
  57. switch (goBack) {
  58. case 1:
  59. login();
  60. break;
  61. case 2:
  62. System.exit(goBack);
  63. }
  64. }
  65. }
  66.  
  67. public static void mainMenu() {
  68. System.out.println("MAIN MENU");
  69. System.out.println("1. Exit");
  70. System.out.println("2. Login");
  71. System.out.println("Enter your choice: ");
  72. selection = inputKeyboard.nextInt();
  73. if (selection < 1 || selection > 2) {
  74. System.out.println("Please Enter 1 for Exit and 2 for Login.");
  75. }
  76. switch (selection) {
  77. case 1:
  78. System.exit(selection);
  79. break;
  80. case 2:
  81. login();
  82. break;
  83. }
  84. // if (correct == false) {
  85. // goBack = inputKeyboard.nextInt();
  86. // if (goBack < 1 || goBack > 2) {
  87. // System.out.println("Please enter 1 to Try Again and 2 to Exit.");
  88. // } else if (goBack == 1 && correct == false) {
  89. // login();
  90. // } else if (goBack == 2 && correct == false) {
  91. // System.out.println("You have exited Math To The Max.");
  92. // System.exit(goBack);
  93. // }
  94. // }
  95. }
  96.  
  97. public static void mainMenu2() {
  98. System.out.println("Welcome " + usernameEntered);
  99. System.out.println("- MATH TO THE MAX MENU -");
  100. System.out.println("1. View High Scores");
  101. System.out.println("2. Play Addition To The Max");
  102. System.out.println("3. Play Subtraction To The Max");
  103. System.out.println("4. Play Multiplying To The Max");
  104. System.out.println("5. Play Division To The Max");
  105. System.out.println("6. Tutorial / FAQ");
  106. System.out.println("7. Exit");
  107. System.out.println("Enter your choice: ");
  108. selectionMainMenu2 = inputKeyboard.nextInt();
  109. if (selectionMainMenu2 < 1 || selectionMainMenu2 > 7) {
  110. System.out.println("Please Enter a Number Between 1 and 7.");
  111.  
  112.  
  113. } else if (selectionMainMenu2 == 1) {
  114. viewHighScores();
  115.  
  116.  
  117. } else if (selectionMainMenu2 == 2) {
  118. addition();
  119.  
  120.  
  121. } else if (selectionMainMenu2 == 3) {
  122. subtraction();
  123.  
  124.  
  125. } else if (selectionMainMenu2 == 4) {
  126. multiplying();
  127.  
  128. }
  129. }
  130. }
  131. /**
  132. * @param args the command line arguments
  133. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement