Skip to content

Instantly share code, notes, and snippets.

@MCMXCIII
Created September 25, 2017 19:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MCMXCIII/83ac217b74f714734ace506aa24eba14 to your computer and use it in GitHub Desktop.
Save MCMXCIII/83ac217b74f714734ace506aa24eba14 to your computer and use it in GitHub Desktop.
import java.util.*;
import java.util.StringTokenizer;
public class NameLab {
public static void main(String a[]){
Scanner sc = new Scanner(System.in);
System.out.println("Enter your last name.");
String lastName = sc.nextLine();
System.out.println("Followed by your first and middle names.");
System.out.println("If you don\"t\" have a middle name enter \"None\".");
String firstName= sc.nextLine();
String middleName = sc.nextLine();
String fullName = firstName + middleName + lastName;
//String msg = "This program gives sample code for String Tokenizer";
StringTokenizer st = new StringTokenizer(fullName,", ");
while(st.hasMoreTokens()){
System.out.println(st.nextToken());
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment