Prog 2: Mastermind

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

Stages

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