Ask Question
29 November, 00:29

In the Guess My Number program, the user continues guessing numbers until the secret number is matched. Assuming numGuesses is initialized to 1, how would the while statement be modified to include an extra criterion limiting the number of guesses to 15?

A) while ((userGuess = = secretNumber) || numGuesses < 14)

B) while ((userGuess= = secretNumber) && numGuesses < = 15)

C) while (! (userGuess = = secretNumber) || numGuesses < 15)

D) while (! (userGuess = = secretNumber) && numGuesses < 15)

E) while (! (userGuess = = secretNumber) && numGuesses < = 15)

+1
Answers (1)
  1. 29 November, 02:47
    0
    E) while (! (userGuess = = secretNumber) && numGuesses < = 15)

    Explanation:

    The first part of this answer! (userGuess = = secretNumber) verifies that the userGuess is not equal to the secretNumber. Yes, the equal sign (double as it should be when comparing things) is between the userGuess and the secretNumber, but all this expression is inside a parenthesis ... which is negated by the! before it.

    The second part verifies tht the numGuesses < = 15 because the counter is initialized at 1, so to get a total of 15 values, we have to go from 1 to 15. If it had been initialized at 0, we would have checked for 14.
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “In the Guess My Number program, the user continues guessing numbers until the secret number is matched. Assuming numGuesses is initialized ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers