Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Project {
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- String[][] names= new String[2][5];
- String userName, password;
- boolean checkPoint=false;
- Scanner myScanner= new Scanner(System.in);
- //Usernames
- names[0][0]= "Username1";
- names[0][1]= "Username2";
- names[0][2]= "Username3";
- names[0][3]= "Username4";
- names[0][4]= "Username5";
- //Passwords
- names[1][0]= "Password1";
- names[1][1]= "Password2";
- names[1][2]= "Password3";
- names[1][3]= "Password4";
- names[1][4]= "Password5";
- //Prompt User for Username/See if Username exists.
- System.out.println("What is the Username?");
- userName=myScanner.nextLine();
- for(int y=0; y<5; y++)
- {
- if(userName.equals(names[0][y]))
- {
- break;
- }
- else
- if(y==4) {
- System.out.println("Username does not exist.");
- System.exit(0);
- }
- }
- //Prompt User for Password, and check password.
- System.out.println("What is the Password");
- password=myScanner.nextLine();
- for(int i=0; i<5; i++)
- for(int k=0; k<2; k++)
- if(userName.equals(names[0][i]))
- {
- if(password.equals(names[k][i]))
- checkPoint=true;
- }
- //Check to see if credentials are correct
- if(checkPoint) {
- System.out.println("Login Successful");
- }
- else {
- System.out.println("Wrong Password!");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement