Username

{ public static void main(String[] args) { Scanner sc = new Scanner(System.in); System.out.println("Enter full name: ");//Adam Nathaniel Kovacs String fullName = sc.nextLine(); String mName =""; String lName = ""; String username = ""; int spot = fullName.indexOf(" "); String fName = fullName.substring(0, spot); fullName = fullName.substring(spot+1); spot = fullName.indexOf(" "); if(spot>0){ mName = fullName.substring(0, spot); fullName = fullName.substring(spot+1); lName = fullName; username = lName.substring(0,4) + fName.substring(0,1) + mName.substring(0,1); }else{ lName = fullName; username = lName.substring(0,4) + fName.substring(0,1); } // mName = mName.substring( System.out.println("Enter: " + username); } }

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.