Preview File Edit View Go Tools Window Help O 215 GB 00 Sun

Preview File Edit View Go Tools Window Help O 2.15 GB 00% Sun Nov 27 4:01:43 PM Q e E Ch.5 Problem Set.pdf e 2 of 2) a Search Ch.5 Problem Set.pdf l. te an interactive program that reads lines of input from the user and converts each line into \"Pig Latin.\" Pig Latin English with the initial consonant sound moved to the end of each word, followed by \"ay.\" Words that begin with els simply have an \"ay\" appended. For example, the phrase The deepest shade of mushroom blue d have the following appearance in Pig Latin y eepest-day ade-shay of-ay ushroom-may ue-blay Terminate the program when the user types a blank line 2. Write a reverse Hangman game in which the user thinks of a word and the computer tries to guess the letters in word. The user tells the computer how many letters the word contains 3. Write a program that plays a guessing game with the user. The program should generate a random number betw and some maximum (such as 100), then prompt the user repeatedly to guess the number. When the user guesses in rectly, the game should give the user a hint about whether the correct answer is higher or lower than the guess. On user guesses correctly, the program should print a message showing the number of guesses that the user made. Consider extending this program by making it play multiple games until the user chooses to stop and then printing statistics about the player\'s total and average number of guesses. 4. Write a program that plays a reverse guessing game with the user. The user thinks of a number between 1 and 10 SONOS

Solution

Answer 1: PigLatin Words import java.io.IOException; import java.util.Scanner; public class PigLatin { public static void main(String args[]) throws IOException { Scanner sc = new Scanner(System.in); System.out.println(\"Enter your sentence.\"); String word = sc.nextLine();// To read the input from the user. while (!word.trim().equalsIgnoreCase(\"\")) { System.out.println(\"The Piglatin sentence = \"); for(String s: word.split(\" \")) { convertStringToPigLatin(s); System.out.print(\" \"); } System.out.println(); System.out.println(\"Enter your sentence.\"); word = sc.nextLine(); } System.out.println(\"Exiting.....\"); } //This method converts the word into Pig latin word. private static void convertStringToPigLatin(String s) { int l=s.length(); // get the length of the word. int position=-1; //initialize the position and character for(int i=0; i
 Preview File Edit View Go Tools Window Help O 2.15 GB 00% Sun Nov 27 4:01:43 PM Q e E Ch.5 Problem Set.pdf e 2 of 2) a Search Ch.5 Problem Set.pdf l. te an int

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site