Question: Write a C + + program that will complete the following steps: 0 . Declare variables a . P 1 _ int _ val, P

Write a C++ program that will complete the following steps:
0. Declare variables
a. P1_int_val, P2_int_val as type int
b. P1_string_val, P2_string_val as type string
1. Use srand(), time(NULL), and rand() to assign a random integer between [0,2] to
P1_int_val and P2_int_val
2. Based off of the numerical values stored inside of P1_int_val and P2_int_val, use if, else, and else if
statements to store the following strings in P1_string_val, P2_string_val
int_val string_val
0 rock
1 paper
2 scissors
3. Output the string_vals of both players to the console.
4. Use a function to compute and return an integer value to determine who won. Try to complete this
step using less than 6 operations.
This function will take in two integers as parameters:
1. P1 this will store a copy of P1_int_val
2. P2 this will store a copy of P2_int_val
This function will return an integer value to indicate a tie or which player won. The following defines
the possible return values:
0 Tie
1 Player 1
2 Player 2
5. Based off of what the function returned in Step 4, Output either Tie or a message stating who won

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!