Skip to content

Commit f512623

Browse files
Merge pull request #34 from Amrita8642/main
Added Usernameavailibilitychecker.java
2 parents 7c76549 + adf5ca9 commit f512623

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

Usernameavailibilitychecker.java

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import java.util.Scanner;
2+
3+
public class UsernameChecker {
4+
public static void main(String[] args) {
5+
// Predefined usernames (like taken usernames in a database)
6+
String[] takenUsernames = {"nisha123", "coderX", "javaPro", "admin", "guest"};
7+
8+
Scanner sc = new Scanner(System.in);
9+
10+
System.out.print("Enter a username: ");
11+
String username = sc.nextLine();
12+
13+
boolean available = true;
14+
15+
// Check if username exists in the taken list
16+
for (String taken : takenUsernames) {
17+
if (taken.equalsIgnoreCase(username)) {
18+
available = false;
19+
break;
20+
}
21+
}
22+
23+
// Show result
24+
if (available) {
25+
System.out.println("✅ Username is available!");
26+
} else {
27+
System.out.println("❌ Username already taken. Try another.");
28+
}
29+
}
30+
}

0 commit comments

Comments
 (0)