Advertisement
Guest User

Untitled

a guest
Dec 12th, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. import java.util.Scanner;
  2. public class PigLatin
  3. {
  4. //-----------------------------------------------------------------
  5. // Reads sentences and translates them into Pig Latin.
  6. //-----------------------------------------------------------------
  7.  
  8. public static void main (String[] args)
  9. {
  10. String sentence, result, another = "y";
  11. Scanner scan = new Scanner (System.in);
  12.  
  13. PigLatinTranslator translator = new PigLatinTranslator();
  14. while (another.equalsIgnoreCase("y"))
  15. {
  16. System.out.println ();
  17. System.out.println ("Enter a sentence (no punctuation):");
  18. sentence = scan.nextLine();
  19.  
  20. System.out.println ();
  21. result = translator.translate (sentence);
  22. System.out.println ("That sentence in Pig Latin is:");
  23. System.out.println (result);
  24.  
  25. System.out.println ();
  26. System.out.print ("Translate another sentence (y/n)? ");
  27. another = scan.nextLine();
  28. }
  29.  
  30. }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement