Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

not really sure why it making my code not do what I want it to. I don't have what it's saying I have and I'm

not really sure why it making my code not do what I want it to. I don't have what it's saying I have and I'm sure it's just some error I missed. please help me fix it and zoom in if needed!

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 numbers 1, 2 and 3 represent the following game pieces 1 = Rock 2 = Paper 3 = Scissors If the user enters 1 (rock) and the computer generates 2 (paper), the computer wins, as paper covers rock. For 2 (paper) and 3 (scissors) 3 wins, as scissors cut paper. But since rock breaks scissors, 1 (rock) wins against 3 (scissors). Generate a random number between 1 and 3 and store it as the computer's choice and read in the user's choice. Determine who the winner is by comparing the computer's choice to the user's choice. There can be nine possible combinations of user and computer-generated entries. You will use if-else-if and the & & operator to make all the combinations happen. Your output should match one of the following examples: Your entry: 1 (rock) Computer generated: 1 (rock) It's a tie! Your entry: 2 (paper) Computer generated: 3 (scissors) Scissors cut paper. Computer wins ! Your entry: 1 (rock) Computer generated: 2 (paper) Paper covers rock. Computer wins! Your entry: 3 (scissors) Computer generated: 1 (rock) Rock breaks scissors. Computer wins ! Your entry: 1 (rock) Computer generated: 3 (scissors) Bock breaks scissors. You win! Your entry: 3 (scissors) Computer generated: 2 (paper) Scissors cut paper. You win! Your entry: 2 (paper) Computer generated: 1 (rock) Paper covers rock, You win! Your entry: 3 (scissors) Computer generated: 3 (scissors) It's a tie! Your entry: 2 (paper) Computer generated: 2 (paper) It's a tie! Invalid entry. The input must be a number between 1 and 3. Your program should incorporate the following objectives: Proper comments/documentation Self-documenting variable names Read in an unsigned integer that can be used as a seed value for the random number generator (the seed value is the first value read Paper covers rock. You win! It's a tie! Your entry: 2 (paper) Computer generated: 2 (paper) It's a tie! Invalid entry. The input must be a number between 1 and 3. Your program should incorporate the following objectives: . Proper comments/documentation Self-documenting variable names . Read in an unsigned integer that can be used as a seed value for the random number generator (the seed value is the first value read in and is necessary for auto-grading your program) Generate a random number between 1 and 3 (for help generating a number between 1 and a maximum range, see the program randomnumbetween 1and_maxrange.cpp posted on Bb under Course Content, Module 3, Lesson 2, 1(a) Read in a number between 1 and 3 that represents the user's choice Output the user's choice, computer's choice, and who wins in the specified format. If the input is invalid a message formatted as specified should be displayed . When the input is as shown in Figure 1 (10 is the seed and 1 is the user's choice), your program should produce the output as shown in Figure 2. Figure 1: (sample input) 1 Figure 2: (sample output) Your entry: 1 (rock) Computer generated: 2 (paper) Paper covers rock. Computer wins! 286488.1697136 5 #include 6 #include 7 8 using namespace std; 9 1e int main() 11 1 12 17 Declare variables and initialize if appropriate 13 unsigned int seed; int maxValue = 3; 15 int minValue = 1; 16 int computerChoice, userchoice; 17 18 17 Seed the random computerChoice generator cin >> seed; 2e srand(seed) 21 22 // Input from user 23 cin >> userChoice; 24 25 11 Generate random number 26 Il computerChoice will be assigned a number in the range [1, 2] 27 computerChoice = rand() % (maxValue minValue + 1) + minValue; 28 29 You will need to add the code to compare the user choice to the computer choice 30 11 and generate the output as specified in the assignment above 31 if (userChoice == 1 && computerChoice == 1) 32 { 33 cout

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_2

Step: 3

blur-text-image_3

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

Statistical And Scientific Database Management International Working Conference Ssdbm Rome Italy June 21 23 1988 Proceedings Lncs 339

Authors: Maurizio Rafanelli ,John C. Klensin ,Per Svensson

1st Edition

354050575X, 978-3540505754

More Books

Students also viewed these Databases questions

Question

How does your firm manage mergers and acquisitions?

Answered: 1 week ago