Advertisement
Guest User

Untitled

a guest
Feb 18th, 2019
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 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.  
  12. while (!menuchoice.equals("q")) {
  13. outerloop:
  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[i])) {
  22. JOptionPane.showMessageDialog(null,"You are now logged in!");
  23. loginamt[i]++;
  24. JOptionPane.showMessageDialog(null, "You are now logged in! \n\nThe total number of logins is " + loginamt[i]);
  25. break outerloop;
  26. }
  27. }
  28. }
  29. }
  30. JOptionPane.showMessageDialog(null, "Incorrect login!");
  31. }
  32. menuchoice = JOptionPane.showInputDialog("Select an option --> \n\n (L)ogin to account\n (q)uit program");
  33. }
  34. }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement