Question: 3. (40 points) Implement the game Bulls and Cows. The program uses a vector of five different digits in the range 0 to 9, e.g.

 3. (40 points) Implement the game "Bulls and Cows." The program

uses a vector of five different digits in the range 0 to

3. (40 points) Implement the game "Bulls and Cows." The program uses a vector of five different digits in the range 0 to 9, e.g. 12345, but not 11346, called a secret number, and it is the user's task to discover this number by repeated guesses. Say the number to be guessed is 67895 and the user guesses 71245; the response should be 1 cow and 1 bull because the user got one digit (7) right but in the wrong position and one digit (5) correct in the right position. The guessing continues until the user gets five bulls and wins, that is, has five digits correct and in the right positions. Print out the number of tries after winning. For the grading purposes add an option that displays the secret number if asked. Also, the secret number should be hard-coded (fixed) in the program. Your program should use at least two exceptions Invalid number_of digits and Duplicated digits, and possibly Invalid_input

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!