Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

implement a game of rock, paper, scissors between a user and the computer. take a look at the specifications for how your program needs to

implement a game of rock, paper, scissors between a user and the computer. take a look at the specifications for how your program needs to operate:

  • The user must be prompted for the number of games the user wants to play.
  • The program should keep track of the score of both the computer and the human.
  • The program should keep running until the number of games specified are completed.
  • During each turn, the computer randomly selects its choice.
  • After each turn, the program should display who won the previous round and the score after that turn.
  • After all matches are played, a summary of the final score is displayed

Here's my code so far:

/*Kitundu Kitundu

*C48424127

*CPSC 1011

*Lab 5

*/

#include

#include

#include

int main(void) {

int R;

int P;

int S;

int matches;

int player;

int playerscore;

int computer;

int compscore;

int choices;

printf("Staring the CPSC 1011 Rock, Paper, Scissors Game! ");

printf("Enter the number of matches to play: ");

scanf("%d", &matches);

for(int i=0; i

printf("Match %d: Enter R for rock, P for paper, or S for scissors: ",matches);

scanf("%d", &matches);

computer=rand()%3+1;

if(choices==R){

if(computer==R){

printf("The computer chose rock. You tied. ");

}

if(computer==P){

printf("The computer chose paper. You lose. ");

}

if(computer==S){

printf("The computer chose scissors. You win! ");

}

}

if(choices==P){

if(computer==R){

printf("The computer chose rock. You win!. ");

}

if(computer==P){

printf("The computer chose paper. You tied. ");

}

if(computer==S){

printf("The computer chose scissors. You lose. ");

}

}

if(choices==S){

if(computer==R){

printf("The computer chose rock. You lose. ");

}

if(computer==P){

printf("The computer chose paper. You win! ");

}

if(computer==S){

printf("The computer chose scissors. You tied ");

}

}

return(0);

}

}

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

Database Systems Design Implementation And Management

Authors: Carlos Coronel, Steven Morris

14th Edition

978-0357673034

More Books

Students also viewed these Databases questions

Question

600 lb 20 0.5 ft 30 30 5 ft

Answered: 1 week ago

Question

Identify three improper customer etiquette behaviors.

Answered: 1 week ago