Basically for my lab, I have to write a program that will take an English sentence provided on the command-line and transforms all its words into lowercase, then translates them into PigLatin. The translation to PigLatin of a word is done by reversing the characters in the word and adding sh at the end of the reversed word. For example:
Dreams are the touchstones of our character is translated to PigLatin:
smaerdsh erash ehtsh senotshcuotsh fosh ruosh retcarahcsh
My TA provided a skeleton of the program that has two static methods:
Main: the main method that implements the logic to solve the problem.
reverseString: a private static void method that takes a String and returns the reverse
of that string.
This is what I have so far.
import java.util.Scanner;
public class PigLatin {
/*
* Process the command-line arguments to translate
* them to Pig Latin
*/
public static void main(String[] args) {
Scanner keyboard = new Scanner(System.in);
System.out.print("Please enter any sequence of characters:");
for (int i = args.length-1; i >=0; i--){
for (int j = args[i].length()-1; j>=0; j--){
System.out.print(args[i].charAt(j));
}
System.out.print(" ");
}
System.out.println();
}
/*
* Returns the reverse of the String
* passed through the parameter word.
*/
private static String reverse(String args) {
return args;
}
}
what I need help with is reversing the argument and finding a way to add "sh" at the end of each word in the array so i can eventually set it to .toLowerCase and display the word in pig latin. I hope someone will be able to help me with this

New Topic/Question
Reply




MultiQuote




|