Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In C++ Write a program to simulate a roll of dice and play a guessing game human vs computer. Your program should ask user for

In C++

Write a program to simulate a roll of dice and play a guessing game human vs computer. Your program should ask user for the number, which is a sum of three dice rolls. Then, program should take a computer's guess. After that, the program should roll a dice three times (keeping the values in an array). Program should determine the winner by the closest guess. For example, if I guessed 10, and computer guessed 12, and the sum of three rolls is 9, I won. If the difference is the same, computer wins. I.e. human wins only if he/she guessed better than the computer did (life is unfair).

Your program should keep the score for the user and computer and display that score after each round. Program should continue until user enters -1.

Extra points: Add a "cheater" function, which will prevent human from winning three times in the row (two times is OK).

Your program should use random numbers, and should use functions to "roll"the dice (populate array), and to determine the guess's difference from the sum. Note, that I expect that you use the same function(s) for both, computer and the human.

Main asks user for the input, calls the function(s) to roll the dice and to determine a deviation of a guess from the sum, and outputs results with the score.

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

Databases Illuminated

Authors: Catherine M. Ricardo, Susan D. Urban, Karen C. Davis

4th Edition

1284231585, 978-1284231588

More Books

Students also viewed these Databases questions

Question

Draw a labelled diagram of the Dicot stem.

Answered: 1 week ago

Question

Understand some techniques for evaluating the HRM function

Answered: 1 week ago