Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- public class PigLatin {
- public static String translation (String translatedWord) {
- String temp = translatedWord.toLowerCase();//method returns the string in lowercase letter
- char [] vowels = {'a', 'e', 'i', 'o', 'u'};
- char firstLetter = temp.charAt(0); //returns a char value at the given index number
- translatedWord = translatedWord.substring(1);
- translatedWord += firstLetter + "ay";
- return translatedWord;
- }
- public static void main(String[] args) {
- Scanner in = new Scanner(System.in);
- System.out.print(" Please enter the English word you would like to translate into Pig Latin: ");
- String translatedWord = in.next();//method finds and returns the next complete input
- System.out.println("English word: " + translatedWord);
- System.out.println("Pig Latin translation: " + translation(translatedWord));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement