If the letter is correct, replace the dashes with the letter
There is some implicit information hidden in this line, which needs to be made explicit for the computer to do it. It is "replace the dashes..." What dashes? The definite article "the" in a sentence implies that the noun it is attached to has already been introduced (or else is public information, like "The Queen of England," because England has only one reigning queen, and pretty much everybody knows her name is Elizabeth II), and this is a subsequent reference to that thing or person. The only dashes we have seen so far are in line 2,
2. Draw dashes (computer displays this)which is most easily understood in the first reading as part of the program startup. Yet here she is doing something to those same dashes in the last line of her program! That last line is necessarily inside the letter guessing iteration, and it sort of implies (but does not say) that the program should print out that line of dashes again after replacing some of them with the letter. It's not hard to move that repeat line up one line so it includes also (now as its first iterated line) printing the row of dashes. Calculating the length of that row is still part of the startup, because the length does not change over the course of the game. But the dashes themselves will be slowly replaced with letters as they are guessed correctly.
So how exactly (still in English!) do you plan to replace those dashes? For starters, you need to maintain the dashes in a variable, so that there is something to replace. I made a variable for that purpose in my program, but I also pointed out that they could alternatively be printed on the fly while measuring the length of the input word. That is now no longer an option. This is a good reason for designing your porgram in English: if you make a bad decision, it's much easier to change the English description than it is to change who-knows-how-many lines of Java.
And then you get to decide whether to make another iteration to step therough the whole word and changer all instances of the correctly guessed letter, replacing the dash for the letter, or else because you are already doing most of the work in an iteration trying to decide if this letter is there at all, pull the substitution into the same loop, but run the loop to completion even if you found an instance -- in case there are multiple occurances of this letter. This is your program, you decide.
"Your mission, should you accept it" -- hmm, it looks like you already did that -- now includes adding this substitution to your program design, either as a separate loop, or else combined with the search. Do that, and then turn the page.
Five Basic Concepts Sequence Iteration Conditional Variables Input/Output
Revised: 2021 June 3