Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The code forboth exercises should be written and compiled in Eclipse. The textfi

ID: 3614008 • Letter: T

Question

The code forboth exercises should be written and compiled in Eclipse. The textfile is in the .Java code

1. Write a program thatstarts with the string variable (object name)first set to your first name and thestring variable last set to your lastname. Both names should be all lowercase. Your program should thencreate a new string that contains your full name in pig latin withthe first letter capitalized for the first and last name. Use onlythe pig latin rule of moving the first letter to the end of the word and adding"ay." Output the pig latin name to the screen. Usethe substring and toUpperCasemethods to construct the new name.

For example,given

first -"bill";

last ="smith";

Explanation / Answer

First, let's write a method to convert to piglatin: publicstatic void convertToPigLatin(String name) { // assume name is atleast 2 letters long // move first letter to the endof the word and add "ay" return Character.toUpperCase(name.charAt(1))+name.substring(2)+Character.toLowerCase(name.charAt(0))+"ay"; } Now, we convert the name to pig latin in our mainmethod. publicstatic void main(String[]args) { // replace with yourfirst & last name String first= "bill"; String last= "smith"; // convert to piglatin String pigFirst= convertToPigLatin(first); String pigLast= convertToPigLatin(last); String pig= pigFirst + " " + pigLast; // output System.out.println(pig); }