Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

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

help! in C++
image text in transcribed
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. Comment your program: Programmer: Your name Purpose: State the purpose of the program. Class: CS222 Assignment number 3. Describe all variables Describe important sections of code. Grading Comments Indentation Meaningful variables names Program runs Correct input and output 2 points 2 points 2 points 4 points 5 points 15 points 2 points Total 11 1117777 Extra: Cheater function Deductions: Not validating user's input -2 points Not declaring array according to standards -2 points off-by one errors -2 points others as deemed appropriate

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions