Write MATLAB code to play a guessing game.
The user tries to guess the secret color (she is allowed a max of 3 guesses).
If the user guesses the color correctly, the game stops and a winning message is shown.
If she does not guess the correct color, a message is shown stating that they lost.
You may not use break
. In both examples below, the secret color is red (you can hard-code your secret color to be red).
Sample output:
>> colorGuess
Guess my secret color: yellow
Guess my secret color: purple
Guess my secret color: green
Sorry, you lost!
>> colorGuess
Guess my secret color: yellow
Guess my secret color: red
You guessed it!