Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import javax.swing.*;
- public class Project1 {
- public static void main(String[] args) {
- String[] usernames = { "x", "banana", "apple", "blueberry", "grape" };
- String[] passwords = { "x", "yellow", "red", "blue", "purple" };
- int[] loginamt = { 0, 0, 0, 0, 0 };
- String menuchoice = JOptionPane.showInputDialog("Select an option --> \n\n (L)ogin to account\n (q)uit program");
- outerloop:
- while (!menuchoice.equals("q")) {
- if (menuchoice.equals("L")) {
- String enteruser = JOptionPane.showInputDialog(null, "Enter username");
- String enterpass = JOptionPane.showInputDialog(null, "Enter password");
- for (int i = 0; i < usernames.length; i++) {
- if (enteruser.equals(usernames[i])) {
- for (int b = 0; b < passwords.length; b++) {
- if (enterpass.equals(passwords[b])) {
- JOptionPane.showMessageDialog(null,"You are now logged in!");
- loginamt[i]++;
- break outerloop;
- }
- }
- }
- }
- JOptionPane.showMessageDialog(null, "Incorrect login!");
- }
- menuchoice = JOptionPane.showInputDialog("Select an option --> \n\n (L)ogin to account\n (q)uit program");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement