Question: Write a method named firstLetter that accepts two parameters: a Scanner for the console, and a first letter represented as a one - letter String.

Write a method named firstLetter that accepts two parameters: a Scanner for the console, and a first letter represented as a one-letter String. The method repeatedly prompts the user until two consecutive words are entered that start with that letter. The method then prints a message showing the last word typed.
You may assume that the user will type a single-word response to each prompt. Your code should be case-sensitive; for example, if the first letter is w, you should not stop prompting if the user types words that start with an W. For example, the following sample shows the output from a calls to your method (output in bold)
firstLetter (console,"y")<--- call to the method, where console is an input Scanner object
Looking for two words in a row starting with an "y"
Type a word: bye
Type a word: yes
Type a word: ???
Type a word: Java
Type a word: yippee
Type a word: yes
starting with "y" is for "yes"

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!