import java.util.*; // This program takes a person's first name and last name as input as plays // the name game with both names. In class we did the first name. Refactor // the code to also print out the lastname that we got from the input string. public class TheNameGame { public static void main(String[] args) { Scanner console = new Scanner(System.in); System.out.print("What is your name? "); String name = console.nextLine(); int indexOfSpace = name.indexOf(" "); String firstName = name.substring(0, indexOfSpace); String lastName = name.substring(indexOfSpace + 1); /* (X), (X), bo-b(X - 1) Banana-fana fo-f(X - 1) Fee-fi-mo-m(X - 1) X! */ System.out.print(firstName + ", " + firstName + ", "); System.out.println("bo -b" + firstName.substring(1)); System.out.println("Banana-fana fo-f" + firstName.substring(1)); System.out.println("Fee-fi-mo-m" + firstName.substring(1)); System.out.println(firstName.toUpperCase() + "!"); } }