Advertisement
Guest User

Untitled

a guest
Feb 25th, 2020
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. import java.util.*;
  2. public class PigLatin {
  3.  
  4. public static String translation (String translatedWord) {
  5. String temp = translatedWord.toLowerCase();//method returns the string in lowercase letter
  6. char [] vowels = {'a', 'e', 'i', 'o', 'u'};
  7. char firstLetter = temp.charAt(0); //returns a char value at the given index number
  8. translatedWord = translatedWord.substring(1);
  9. translatedWord += firstLetter + "ay";
  10. return translatedWord;
  11. }
  12.  
  13. public static void main(String[] args) {
  14. Scanner in = new Scanner(System.in);
  15. System.out.print(" Please enter the English word you would like to translate into Pig Latin: ");
  16. String translatedWord = in.next();//method finds and returns the next complete input
  17. System.out.println("English word: " + translatedWord);
  18. System.out.println("Pig Latin translation: " + translation(translatedWord));
  19. }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement