Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ Assignment The program should follow these steps: 1. When the program begins, a random number in the range of 1 through 3 is generated.

C++ Assignment

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

The program should follow these steps: 1. When the program begins, a random number in the range of 1 through 3 is generated. If the number is 1, then the computer has chosen rock. If the number is 2, then the computer has chosen paper. If the number is 3, then the computer has chosen scissors. (Don't display the computer's choice before the user has played!!!) 2. The following menu is displayed to the user: Game Menu 1) Rock 2) Paper 3) Scissors 4) Quit 3. The user is prompted for their choice. If they enter 1, their choice is rock. If they enter 4, then the game ends. Input validation loop: If the user enters anything other than 1-4, the menu should come back up again until the user enters something valid. 4. The user's choice is displayed. 5. The computer's choice is displayed. 6. The outcome of the game is determined according to the following rules: A. If one player chooses rock and the other player chooses scissors, then rock wins. (The rock smashes the scissors.) B. If one player chooses scissors and the other player chooses paper, then scissors wins. (Scissors cuts paper.) C. If one player chooses paper and the other player chooses rock, then paper wins. (Paper wraps rock.) D. If both players make the same choice, then a tie has occurred. Also make sure to seed the random number generator, so the program doesn't generate the same sequence of random numbers each time it is run. The main function has already been completed for you. In addition, the function prototypes and function headers have also been completed for you. You will be implementing the body of the following functions: int getComputerChoicel) INPUT(S): No input parameters RETURNS: The computers choice (1, 2, or 3) PURPOSE: // The getComputerChoice function returns the computer's * // game choice. It returns 1 for rock (via the ROCK * // constant), or 2 for paper (via the PAPER constant), // or 3 for scissors (via the SCISSORS constant). * // ...** * int getUserChoicel) INPUT(S): No input parameters RETURNS: The user's choice (1, 2, 3, or 4) PURPOSE: // * // The getUserChoice function displays a menu allowing * // function then returns 1 for rock (via the ROCK * // constant), or 2 for paper (via the PAPER constant) // or 3 for scissors (via the SCISSORS constant), * // or 4 for quit (via the QUIT constant). * INPUT(S): The user's or computers choice (1, 2, or 3) RETURNS: Nothing is returned PURPOSE: // soos // The displayChoice function accepts an integer argument * // and displays rock, paper, or scissors. INPUT(S): The user's choice (1, 2, or 3) and the computers choice (1, 2, or 3) RETURNS: Nothing is returned PURPOSE: // The determineOutcome function accepts the user's game * // choice and the computer's game choice as arguments and * // displays a message indicating the winner // ****************************************************** Game Menu - - - - - - - - - 1) Rock 2) Paper 3) Scissors Enter your choice: 1 The computer selected: Scissors YOU win! Rock smashes scissors. Game Menu 1) Rock 2) Paper 3) Scissors 4) Quit Enter your choice: 2 You selected: Paper The computer selected: Scissors Computer wins! Scissors cuts paper. 1) Rock 2) Paper 3) Scissors 14) Quit Enter your choice: 3 You selected: Scissors The computer selected: Scissors Tie. No winner. Game Menu 1) Rock 2) Paper 3) Scissors Enter your choice: 2 The computer selected: Rock Game Menu 1) Rock 3) Scissors 4) Quit Enter your choice: 3 You selected: Scissors Computer wins! Rock smashes scissors. Game Menu - - - - - - - - - 1) Rock Enter your choice: 1 You selected: Rock The computer selected: Rock Tie. No winner. Game Menu - - - - - - - - - 1) Rock 2) Paper 3) Scissors 4) Quit Enter your choice: 0 Invalid selection. Enter 1, 2, 3, or 4: -1 Invalid selection. Enter 1, 2, 3, or 4: 5 Invalid selection. Enter 1, 2, 3, or 4: 6 Invalid selection. Enter 1, 2, 3, or 4: 1 You selected: Rock The computer selected: Scissors YOU win! Rock smashes scissors. 2) Paper 3) Scissors 4) Quit Enter your choice: 4

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

Essentials of Database Management

Authors: Jeffrey A. Hoffer, Heikki Topi, Ramesh Venkataraman

1st edition

133405680, 9780133547702 , 978-0133405682

Students also viewed these Databases questions

Question

understand the diversity and complexity of ageing in the workplace;

Answered: 1 week ago

Question

Summarize various training methods.

Answered: 1 week ago

Question

Explain the metrics for evaluating training and development.

Answered: 1 week ago

Question

Identify career planning approaches.

Answered: 1 week ago