/**
* David Huang
* EA Username Generator
*/
import java.util.*;
public class EAusernameGenerator
{
public static void main(String args[]){
Scanner sc = new Scanner(System.in);
System.out.println("Enter your full name: ");
String fullName = sc.nextLine();
int spot = fullName.indexOf("");
String fullname = fullName.substring(0,spot);
fullname = fullname.substring(spot+1);
spot = fullName.indexOf(" ");
System.out.println("Enter your graduation year");
String year = sc.nextLine();
if (spot > 0) {
String mName = fullName.substring(0,spot);
String lName = fullname.substring(spot + 1);
int lLength = lName.length();
if (lLength <= 3) {
System.out.println("Your username is "+lName.substring(0)+fullName.substring(0,1)+(mName.substring(0,1)+year.substring(2)));
}else{
System.out.println("Your username is "+lName.substring(0,4)+fullName.substring(0,1)+(mName.substring(0,1)+year.substring(2)));
}
}else{
String lName = fullName.substring(0);
int lLength = lName.length();
if (lLength <= 3) {
System.out.println(("Your username is "+lName.substring(0)+fullName.substring(0,1)+year.substring(2)));
}
}
}
}
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.