There is a "fun" children's game where one child thinks of a "common phrase", then the second child repeatedly makes guesses as to the letters that it contains.
You are to write a Java program that:
1. Prompts a user to enter a "common phrase", and reads it into a variable using Scanner.nextLine() - under th assumption that the phrase consists of nothing but undercase letters and spaces.
2. The following is than repeated until the entire "common phrase" is revealed:
* The "common phrase" is displayed with all of the letters (that have not yet been correctly guessed) replaced with the ? character and all of the letters that have been correctly guessed displayed as is.
* Using a user input validation loop, the second user is prompted to enter a single lowercase letter guess.
Hints:
* Store the letters that have been correctly guessed in an initially empty ("") String object, using the concatenation operator (+=).
Sample run(s):
Please enter the phrase to guess at : who do you love
Common Phrase
-------------
??? ?? ??? ????
Enter a lowercase letter guess : f
Common Phrase
-------------
??? ?? ??? ????
Enter a lowercase letter guess : o
Common Phrase
-------------
??o ?o ?o? ?o??
Enter a lowercase letter guess : s
Common Phrase
-------------
??o ?o ?o? ?o??
Enter a lowercase letter guess : w
Common Phrase
-------------
w?o ?o ?o? ?o??
Enter a lowercase letter guess : h
Common Phrase
-------------
who ?o ?o? ?o??
Enter a lowercase letter guess : d
Common Phrase
-------------
who do ?o? ?o??
Enter a lowercase letter guess : e
Common Phrase
-------------
who do ?o? ?o?e
Enter a lowercase letter guess : y
Common Phrase
-------------
who do yo? ?o?e
Enter a lowercase letter guess : u
Common Phrase
-------------
who do you ?o?e
Enter a lowercase letter guess : l
Common Phrase
-------------
who do you lo?e
Enter a lowercase letter guess : v
Common Phrase
-------------
who do you love