/*
*
*/
/**
* @author (Alex Lee)
* @version (09/12/17)
*/
import java.util.*;
public class EAUsernameGen//class header
{
//every open bracket need a closed bracket
//main method below is ignition of a program (not every class has one)
public static void main(String[] args) {
boolean goAgain = true;
while(goAgain){
Scanner sc = new Scanner(System.in);
System.out.println("\nEnter your first, middle, and last name. ");
String fullName = sc.nextLine();
int index1 = fullName.indexOf(" ");
int lNameLength;
index1 = fullName.indexOf(" ");
System.out.println("\nEnter your year of graduation");
String gradYear = sc.nextLine();
String fName = fullName.substring(0,index1);
String mName = fullName.substring(index1+1,index1+2);
fullName = fullName.substring(index1+1);
index1 = fullName.indexOf(" ");
String lName = fullName.substring(index1+1);
System.out.println("\n" + fName);
System.out.println("\n" + mName);
System.out.println("\n" + lName);
if(lName.length() < 4){
lNameLength = lName.length();
}else{ lNameLength = 4;
}
System.out.println("\n" + lName.substring(0,lNameLength) + fName.substring(0,1) + mName.substring(0,1) + gradYear.substring(2));
System.out.println("\n To create another username press 1, any other number to exit.");
int cont = sc.nextInt();
if(cont != 1) //! means not = to 1
goAgain = false;
}//end of while
}// end of static
}
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.