Pig Latin with Scanner answer:
import java.util.Scanner;
/**
* Take in the first and last name and display the pig latin
version with proper capitalization
*
* @author Kris Pepper
* @version 2/21/2012
*/
public class PigLatin
{
public static void main()
{
Scanner theScannerMan = new
Scanner(System.in);
System.out.println("Please enter
your first name");
String first =
theScannerMan.nextLine();
System.out.println("Please enter
your last name");
String last =
theScannerMan.nextLine();
System.out.println("Your pig latin
name is "+ makePig(first) + " " + makePig(last));
}
public static String makePig(String wordToChange)
{
String notCapitalized =
wordToChange.substring(1) + wordToChange.substring(0,1) + "ay";
notCapitalized =
notCapitalized.toLowerCase();
String newfirst =
notCapitalized.substring(0,1);
return
newfirst.toUpperCase() + notCapitalized.substring(1);
}
}