Write a program that will ask the user to input a phrase


Problem

Write a program that will ask the user to input a phrase (multiple word sentence), and an integer value. A static method will be created that takes the sentence (string) and integer as input parameters and returns a single word (string) of that sentence. If the integer was the number three, then the word returned would be the third word in the sentence. If the integer given in zero or negative, simply return an empty string. (do not let it crash) If the integer given is higher than the number of words in the sentence, then just return the last word. The main will ask the user for the inputs, show the output and will give the user the choice to enter in new information (repeatable). This should repeat until the user says that they are done. The static function will not do any inputting or outputting, it simply finds the word and returns it to the main as a string. Do not use StringTokenizer to break up string and do not use the split method from the String class. I want you to do the hard work of searching for spaces between words. You may assume each space in the input is the transition between words. This means that adding multiple spaces between words will mess with your count of words.

Request for Solution File

Ask an Expert for Answer!!
JAVA Programming: Write a program that will ask the user to input a phrase
Reference No:- TGS03261574

Expected delivery within 24 Hours