In: Computer Science
Write a program call FancyMyName which asks you to write a program that tests the usage of different methods for working with Strings.
This program will ask the user to enter their first name and their last name, separated by a space.
Read the user's response using Scanner. Separate the input string up into two strings, one containing the first name and one containing the last name. You can accomplish this by using the indexOf() hint*** find the position of the space, and then using substring() to extract each of the two names. Also output the number of characters in each name (first & last) and output the user's initials. The initials are the first letter of the first name together with the first letter of the last name
A sample run of the program should look something like this:
Please enter your first name and last name, separated by a space?
You entered the name: Steve Henry
Your first name is Steve: has 5 characters
Your last name is Henry: has 5 characters
Your initials are: SH
import java.util.Scanner; public class FancyMyName1 { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); String first, last; System.out.println("Please enter your first name and last name, separated by a space?"); System.out.print("You entered the name: "); first = scanner.next(); last = scanner.next(); System.out.println("Your first name is "+first+": has "+first.length()+" characters"); System.out.println("Your first name is "+last+": has "+last.length()+" characters"); System.out.println("Your initials are: "+first.charAt(0)+last.charAt(0)); } }