(This is a version with input of an exercise from Chapter 1.) Write a program that inputs two string variables, first and last , which the user should enter with his or her name. First, convert both strings to all lowercase. Your program should then create 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.” Output the pig latin name to the screen. Use the substring and toUpperCase methods to construct the new name.
For example, if the user inputs “Walt” for the first name and “Savitch” for the last name, then the program should create a new string with the text “Altway Avitchsay” and print it.
import java.util.*;
public class PigLatin {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner input=new Scanner(System.in);
String firstname,lastname,lower_first,lower_last,latin_first,latin_last;
System.out.println("Enter the First Name:");
firstname=input.next();
System.out.println("Enter the Last Name:");
lastname=input.next();
System.out.println("Full Name before PigLatin:"+ firstname+" "+ lastname);
lower_first=firstname.toLowerCase();
lower_last=lastname.toLowerCase();
latin_first=lower_first.substring(1,2).toUpperCase()+lower_first.substring(2)+lower_first.substring(0,1)+"ay";
latin_last=lower_last.substring(1,2).toUpperCase()+lower_last.substring(2)+lower_last.substring(0,1)+"ay";
System.out.println("Full Name after modifying PigLatin:"+ latin_first +" "+ latin_last);
}
}