Question: C++ ONLY Write a program similar to Mastermind, except you will use 3 digits instead of colors. Running the program should look like the following:

C++ ONLY

Write a program similar to Mastermind, except you will use 3 digits instead of colors. Running the program should look like the following:

Program: 2 MasterMind The program selects 3 distinct random digits 0..9. On each turn you guess 3 digits. The program indicates how many are correct. You have 10 moves to guess the number. Good luck! Press 's' to set the three digits, or 'r' to randomize them: r Input of 000 displays the hidden digits. Input of 999 exits the program. In place Out of place -------- ------------ 1. Your guess: 012 You entered: 012 0 0 2. Your guess: 345 You entered: 345 0 1 3. Your guess: 637 You entered: 637 0 2 4. Your guess: 783 You entered: 783 2 0 5. Your guess: 793 You entered: 793 3 0 *** Congratulations! *** Exiting program... 

Alternatively if you are not able to find the answer within ten moves, a message and the answer is displayed, as follows:

Program: 2 MasterMind The program selects 3 distinct random digits 0..9. On each turn you guess 3 digits. The program indicates how many are correct. You have 10 moves to guess the number. Good luck! Press 's' to set the three digits, or 'r' to randomize them: r Input of 000 displays the hidden digits. Input of 999 exits the program. In place Out of place -------- ------------ 1. Your guess: 012 You entered: 012 0 0 2. Your guess: 123 You entered: 123 1 0 3. Your guess: 234 You entered: 234 0 1 4. Your guess: 345 You entered: 345 0 1 5. Your guess: 456 You entered: 456 0 0 6. Your guess: 567 You entered: 567 0 1 7. Your guess: 158 You entered: 158 0 0 8. Your guess: 289 You entered: 289 0 1 9. Your guess: 389 You entered: 389 0 2 10. Your guess: 894 You entered: 894 1 0 Better luck next time. Exiting program... 

Notes

I suggest you store the digits to be guessed as separate values, either as int or char values. When choosing 's' to set the digits to be guessed, note that input has all three digits entered next to each other, with no spaces between them.

As in the previous program, do not use srand(), as it will cause your program's output to not match the expected output.

When generating the three original values to be guessed, for the second and third values you should somehow use a loop to ensure that those values are distinct from the previous values already chosen. Using break and continue can help with this.

Stages

Write your program in stages as follows, where the number of points for each stage is shown:

(20 points) Display the instructions and find and display the three distinct characters in the range 0..9. Running your program should look like:

 

Program: 2 MasterMind The program selects 3 distinct random digits 0..9. On each turn you guess 3 digits. Program indicates how many are correct. You have 10 moves to guess the number. Good luck! Press 's' to set the three digits, or 'r' to randomize them: r Values to guess are: 367 Exiting...

NOTE; OUTPUT FOR "000" AND "999" SHOULD LOOK LIKE THIS

In place Out of place

-------- ------------

1. Your guess:

You entered: 123 0 1

2.Your guess:

Hidden digits are: 367

2. Your guess:

You entered: 456 0 1

3. Your guess:

Exiting loop...

Better luck next time

. Exiting program...

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!