usernamemaker

/** * Write a description of class EAUsernameGen here. *converts name to EA username * @author (Rahul Khullar) * @version (9/12/17) */ import java.util.*; import java.util.Random; public class EAUsernameGen { // instance variables - replace the example below with your own public static void main(String args[]){ Scanner scan = new Scanner(System.in); Scanner scan2 = new Scanner(System.in); System.out.println("Please input your full name"); String name = scan.nextLine(); System.out.println("Please input your Graduation year"); String Gradyear = scan2.nextLine(); String firstname = name.substring(0, 1); int point = name.indexOf(" "); String middlename = name.substring(point + 1, point + 2); int point2 = name.indexOf(" ", point + 1); String lastname = name.substring(point2 + 1); if (point2 != -1){ if (lastname.length() < 4){ lastname = name.substring(point2 + 1); middlename = ""; } else if (lastname.length() > 3){ lastname = name.substring(point2 + 1, point2 + 5); } } else{ if (lastname.length() < 4){ lastname = name.substring(point + 1); middlename = ""; } else if (lastname.length() > 3){ lastname = name.substring(point + 1, point + 5); } } System.out.println(point2); String year = Gradyear.substring(2,4); System.out.println(lastname + firstname + middlename + year); } }

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.