Question
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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started