Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In C++ I need help writing a Bulls and Cows game. The game is to only run ONCE in other words you get only one

In C++ I need help writing a Bulls and Cows game. The game is to only run ONCE in other words you get only one chance to guess the random number before you have to execute the file again and try another random five digit number. Also, there must be at least two exceptions one for repeat of double digits and one for an invalid input. I will post the following problem and code that I have written so far.

image text in transcribedimage text in transcribedimage text in transcribed

(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. (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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advances In Databases And Information Systems Uropean Conference Adbis 2020 Lyon France August 25 27 2020 Proceedings Lncs 12245

Authors: Jerome Darmont ,Boris Novikov ,Robert Wrembel

1st Edition

3030548317, 978-3030548315

More Books

Students also viewed these Databases questions

Question

Understanding Group Affiliations?

Answered: 1 week ago

Question

Bachelors degree in Information Systems or Statistics

Answered: 1 week ago