-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUserAuth.java
More file actions
25 lines (21 loc) · 801 Bytes
/
UserAuth.java
File metadata and controls
25 lines (21 loc) · 801 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import java.util.Scanner;
public class UserAuth {
public static void main(String[] args) {
try (Scanner input = new Scanner((System.in))) {
String userName = "ryan";
String password = "1234";
while (true) {
System.out.print("Enter username: ");
String uName = input.nextLine();
System.out.print("Enter password: ");
String uPassword = input.nextLine();
if (uName.equals(userName) && uPassword.equals(password)) {
System.out.println("Welcome " + uName);
break;
} else {
System.out.println("Incorrect username & password. Please try again.\n");
}
}
}
}
}