You are to write a Java program that: 1. Prompts a user to enter a \"common phra
ID: 3632075 • Letter: Y
Question
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 (+=).
do not use arrays
Explanation / Answer
public class TakeHomeExam { public static void main(String[] args) { Scanner stdIn = new Scanner(System.in); String guess= ""; System.out.print("Please enter the phrase to guess at : "); String commonPhrase= stdIn.nextInt(); for (int i=0; iRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.