-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUsernameGenerator.java
More file actions
50 lines (37 loc) · 1.62 KB
/
UsernameGenerator.java
File metadata and controls
50 lines (37 loc) · 1.62 KB
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
//Program Name: Username Generator
//Author: Joshua Decker
//Class: CSC110
//Date Written: 2/12/2020
//Brief Description: Generates a two unique usernames based on input from user.
package ch3;
import java.util.Random;
import java.util.Scanner;
public class UsernameGenerator {
public static void main(String[] args) {
Scanner scnr = new Scanner(System.in);
Random gen = new Random();
String firstName, lastName, birthYear, username1, username2;
System.out.println("Welcome. This program will help you create a username.");
System.out.println("Enter your first name: ");
firstName = scnr.nextLine();
System.out.println("Enter your last name:");
lastName = scnr.nextLine();
System.out.println("Enter four digit birthyear:");
birthYear = scnr.nextLine();
username1 = firstName.charAt(1) + "$" + birthYear.substring(2, 4) + lastName.toUpperCase() + (gen.nextInt(100 ) + 1);
username2 = firstName.substring(0,2) + firstName.length() + "$" + lastName.substring(lastName.length() - 2, lastName.length()) + (gen.nextInt(26) + 50);
System.out.println("Here are the two possible usernames generated for you: ");
System.out.println("Username1: " + username1 + " Length: " + username1.length());
System.out.println("Username2: " + username2 + " Length: " + username2.length());
}
}
/*Welcome. This program will help you create a username.
Enter your first name:
Joshua
Enter your last name:
Decker
Enter four digit birthyear:
1988
Here are the two possible usernames generated for you:
Username1: o$88DECKER44 Length: 12
Username2: Jo6$er65 Length: 8 */