Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import javax.swing.*;
- public class UserLogin {
- public static void main(String[] args) {
- String[] usernames = { "x", "jimmy12", "john05" , "lauren01", "katie90"};
- String[] passwords = { "x", "mets7654", "bass1276", "beauty0000", "password2176"};
- boolean done = false;
- do {
- String input = JOptionPane.showInputDialog("(l)ogin to account\n(q)uit program");
- if (input.equalsIgnoreCase("q")) {
- done = true;
- } else {
- String username = JOptionPane.showInputDialog("Enter username");
- String password = JOptionPane.showInputDialog("Enter password");
- String message = "Invalid try again";
- for(int i = 0; i < usernames.length; i++) {
- if (usernames[i].equalsIgnoreCase(username)) {
- if (passwords[i].equals(password)) {
- message = "you are logged in";
- done = true;
- break;
- }
- }
- }
- JOptionPane.showMessageDialog(null, message);
- }
- } while (!done);
- }
- }
Add Comment
Please, Sign In to add comment