Skip to content

Instantly share code, notes, and snippets.

@spukles
Created September 21, 2022 20:19
Show Gist options
  • Save spukles/19a2bfae1f4403f0d375ca4d4a82c8c9 to your computer and use it in GitHub Desktop.
Save spukles/19a2bfae1f4403f0d375ca4d4a82c8c9 to your computer and use it in GitHub Desktop.
import java.util.Scanner;
import java.util.Random;
public class GenName{
public static void main (String[] args){
//Scanner & random & int
Scanner input = new Scanner (System.in);
//Random number generator build
Random generator = new Random();
int num1;
//Random number in the range 10 to 99
num1 = generator.nextInt((90)+10);
Random rnd = new Random();
//String object
String firstName;
String lastName;
String concatenatedName;
//Get First & Last names
System.out.print("First Name:");
firstName = input.next();
System.out.print("Last Name:");
lastName = input.next();
//String of the first four characters of the user's last names
//String of the first two letters of the user's first names
concatenatedName = lastName.substring(0,4) + firstName.substring(0,2) + num1;
System.out.println(concatenatedName);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment