Question: Create a class called Lab that contains the partial program below, which when complete will convert a name into its corresponding pig latin name. //***************************************************************
Create a class called Lab that contains the partial program below, which when complete will convert a name into its corresponding pig latin name.
//***************************************************************
//
//Purpose: Create a method that will convert a name into its corresponding
// pig latin name.
//***************************************************************
public class Lab6
{
public static void main(String[] args)
{
// (1) Declare String variables firstName and lastName.
// (2) Prompt and retrieve initial values for firstName and lastName. Ask the user to use all lowercase letters.
// (3) Declare a new String variable that will contain the pig latin name.
// (5) Invoke the method pigLatin and pass the firstName and lastName as parameters. Assign the returned String value to the variable you declared in (3).
// (6) Output the pig latin name to the screen.
}
// (4) Write a static method that will convert the full name into pig latin.
//Use the following method header
public static String pigLatin (String fName, String lName)
}
Your method pigLatin() should create and return a new string that contains the full name in pig latin with the first letter capitalized for the first and last name. Use only the pig latin rule of moving the first letter to the end of the word and adding ay. Use the substring and toUpperCase methods to construct the new name.
For example, given
first = "daniel";
last = "liang";
the method should return a new string with the text AnielDay IangLay.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
