Advertisement
Guest User

Untitled

a guest
Feb 18th, 2019
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. import javax.swing.*;
  2.  
  3. public class Project1 {
  4.  
  5. public static void main(String[] args) {
  6. String[] usernames = { "x", "banana", "apple", "blueberry", "grape" };
  7. String[] passwords = { "x", "yellow", "red", "blue", "purple" };
  8. int[] loginamt = { 0, 0, 0, 0, 0 };
  9.  
  10. String menuchoice = JOptionPane.showInputDialog("Select an option --> \n\n (L)ogin to account\n (q)uit program");
  11. outerloop:
  12. while (!menuchoice.equals("q")) {
  13.  
  14. if (menuchoice.equals("L")) {
  15. String enteruser = JOptionPane.showInputDialog(null, "Enter username");
  16. String enterpass = JOptionPane.showInputDialog(null, "Enter password");
  17.  
  18. for (int i = 0; i < usernames.length; i++) {
  19. if (enteruser.equals(usernames[i])) {
  20. for (int b = 0; b < passwords.length; b++) {
  21. if (enterpass.equals(passwords[b])) {
  22. JOptionPane.showMessageDialog(null,"You are now logged in!");
  23. loginamt[i]++;
  24. break outerloop;
  25. }
  26. }
  27. }
  28. }
  29. JOptionPane.showMessageDialog(null, "Incorrect login!");
  30. }
  31. menuchoice = JOptionPane.showInputDialog("Select an option --> \n\n (L)ogin to account\n (q)uit program");
  32. }
  33. }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement