Question
need help, dont understand how to set up.
1 You are a game developer at Microsoft Corporation and are charged with the task of developing games in C++. 2 Please develo
A. Player One: person You need to ask the person to enter one option from the above three. 10 B. Player Two: computer The sys
D. When the player wins, the player got 1 score for each round. If it is a draw, both players got 0 score. E. The game should
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Ans:-

Code:

#include<iostream>
#include<time.h>

using namespace std;

int main()
{
int score_p1=0,score_p2=0;
char answer = 'y';
cout<<"select from following options"<<endl;
cout<<"1. Rock"<<endl;
cout<<"2. paper"<<endl;
cout<<"3. scissor"<<endl;
while(answer=='Y' || answer =='y')
{
int p1, p2;
cout<<"select one option from above three"<<endl;
cout<<"p1 =";
cin>>p1;
  
srand(time(NULL));

p2= rand()%3 + 1;
cout<<"p2 = "<<p2<<endl;
  
if((p1+p2)%2!=0)
{
if(p1>p2)
{
cout<<"p1 wins"<<endl;
score_p1+=1;
}
else
{
cout<<"p2 wins"<<endl;
score_p2+=1;
} }
  
else
{
if(p1<p2)
{
cout<<"p1 wins"<<endl;
score_p1+=1;
}
else if(p1==p2)
cout<<"Draw"<<endl;
else
{
cout<<"p2 wins"<<endl;
score_p2+=1;
}
}
cout<<"would you like to continue Y/y or N/n"<<endl;
cin>>answer;
}
cout<<"final score of p1 is "<<score_p1<<endl;
cout<<"final score of p2 is "<<score_p2<<endl;
if(score_p1 > score_p2)
cout<<"You wins"<<endl;
else if(score_p1 == score_p2)
cout<<"Draw"<<endl;
else
cout<<"Computer wins"<<endl;
return 0;
}

Screenshot of code:-

Run Debug Stop e Share Save {} Beautify Language C++ @ main.cpp #include<iostream> 2 #include<time.h> 4 using namespace std;

Output:

Willy UPLIUS 1. Rock 2. paper 3. scissor select one option from above three pl =2 p2 = 2 Match draw would you like to continu

P.S. - If you find my answer useful, please take a second to give it a THUMBS UP.

Add a comment
Know the answer?
Add Answer to:
need help, dont understand how to set up. 1 You are a game developer at Microsoft...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a program that plays the popular scissor-rock-paper game. (A scissor can cut a paper, a...

    Write a program that plays the popular scissor-rock-paper game. (A scissor can cut a paper, a rock can knock a scissor, and a paper can wrap a rock.) The program randomly generates a number 0, 1, or 2 representing scissor, rock, and paper. The program prompts the user to enter a number 0, 1, or 2 and displays a message indicating whether the user or the computer wins, loses, or draws. Here are sample runs: Enter your selection: scissor (0),...

  • please help me fix this. I'm getting it all mixed up in user defined functions. here's...

    please help me fix this. I'm getting it all mixed up in user defined functions. here's the question. This week we'll write a C program that lets the user play the game of Rock, Paper, Scissors against the computer. Your program will call a user-defined function named display_rules that displays the rules of the game. It then proceeds to play the game. To determine the winner, your program will call another user- defined function called determine_winner that takes two integer...

  • Assignment C++: Rock-Scissor-Paper & Tic-Tac-Toe i need you to write two different program for RSP and...

    Assignment C++: Rock-Scissor-Paper & Tic-Tac-Toe i need you to write two different program for RSP and TTT: R-S-P Requirement: - write one program that mimics the Rock-Scissor-Paper game. This program will ask user to enter an input (out of R-S-P), and the computer will randomly pick one and print out the result (user wins / computer wins). - User's input along with computer's random pick will be encoded in the following format: -- user's rock: 10 -- user's scissor: 20...

  • Good evening, here is a C program question. I wanna to write a very small game....

    Good evening, here is a C program question. I wanna to write a very small game. The rule of the game is like rock scissors. Both of the player and the computer generate a letter taking the value A, B, C. And A<B, B<C, C<A (Like rock scissors game, rock<cloth, cloth< scissor, scissor<rock) Requirement 1: New users need to register an account with a username and password. Actually, the account should be a structure type variable containing: a username, a...

  • Python Language: Please see program listed below of a game called: Rock, Paper, Scissors. Please add...

    Python Language: Please see program listed below of a game called: Rock, Paper, Scissors. Please add an exception, for example if the user inputs something else other than rock, paper or scissors, the exception will print message: "Enter only rock, paper, or scissors". Also add option to keep playing the game, for example: print: "Would you like to play again? Enter Y or N". If the user says Y, the game will repeat, if N, the game will end and...

  • This program should be in c++. Rock Paper Scissors: This game is played by children and...

    This program should be in c++. Rock Paper Scissors: This game is played by children and adults and is popular all over the world. Apart from being a game played to pass time, the game is usually played in situations where something has to be chosen. It is similar in that way to other games like flipping the coin, throwing dice or drawing straws. There is no room for cheating or for knowing what the other person is going to...

  • Good evening, here is a C program question. I wanna to write a very small game....

    Good evening, here is a C program question. I wanna to write a very small game. The rule of the game is like rock scissors. Both of the player and the computer generate a letter taking the value A, B, C. And A<B, B<C, C<A (Like rock scissors game, rock<cloth, cloth< scissor, scissor<rock) Requirement 1: New users need to register an account with a username and password. Actually, the account should be a structure type variable containing: a username, a...

  • (c++ only)Write a program that lets the user play the game of Rock, Paper, Scissors against...

    (c++ only)Write a program that lets the user play the game of Rock, Paper, Scissors against the computer. The program should work as follows: When the program begins, the user enters his or her choice of “rock”, “paper”, or “scissors” at the keyboard using a menu in a function, userChoice, that returns a character. Next, there should be a function, computerChoice, that generates the computer’s play. A random number in the range of 1 through 3 is generated. If the...

  • Write a program in the Codio programming environment that allows you to play the game of...

    Write a program in the Codio programming environment that allows you to play the game of Rock / Paper / Scissors against the computer. Within the Codio starting project you will find starter code as well as tests to run at each stage. There are three stages to the program, as illustrated below. You must pass the tests at each stage before continuing in to the next stage.  We may rerun all tests within Codio before grading your program. Please see...

  • Need help, a bit confused. Thank you. 2) (10 points) Assuming there is an offline game,...

    Need help, a bit confused. Thank you. 2) (10 points) Assuming there is an offline game, once players finish the game, the final score would be stored in a score file. Now we have multiple players playing that game. Each player needs to play that game in two computers "Alpha" and "Beta". So there are two score files generated separately in two computers. Our goal is to check those two files and join the score for each player together to...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT