Last active
December 26, 2015 08:39
-
-
Save joeyv/7123579 to your computer and use it in GitHub Desktop.
Generates a username based off of the first letter of your name, the first 5 letters of your last name, and a random 2 digit number.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.util.*; | |
| public class Usernames { | |
| public static void main(String[] args) { | |
| String first, last, username; | |
| int randomNum; | |
| // Scan in first and last name | |
| Scanner scan = new Scanner(System.in); | |
| first = scan.next(); | |
| last = scan.next(); | |
| // Create random number 10-99 | |
| // add 10 so the lowest number generated is 10 | |
| // randomize 90 numbers because 0 counts as a number | |
| Random generator = new Random(); | |
| randomNum = generator.nextInt(90) + 10; | |
| // Display custom username | |
| username = first.charAt(0) + last.substring(0, 5) + randomNum; | |
| System.out.println(username); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment