Zookal
Zookal

We’d love to hear any feedback or comment from you!

© 2011-2021 Zookal Pty Ltd

View question and answer

From our collection of questions and answers
Engineering · Computer Science
Question details

I wrote a code that play rock, paper, scissors in with the user in C programming and put it below. How would I use my rock, paper, scissors code to do the rest of the bullet points in C Programming (NOT C++) in the image posted? Please if possible screenshot how it would look like with it compiled. Thanks.

Goals 1. Create a program that tallies game outcomes using arrays Tasks Write code that calculates statistics for playing your Rock/Paper/Scissors game Change your program to make each round of the game a separate function call (e.g. a function called PlayRPS0 results in playing exactly one game with the user) Ask the user how many times to play, then call the function that many times Maintain the counts for each move (selected by either player) in an array you may use a global array this time only because you dont know yet how to do it differently) After you have played the requested number of times print the statistics for the user Make sure that your code compiles and runs successfully Submit your main.c C code via Worksheet Assignment 18 in Blackboard Some example runs of the program are shown in the table below. Play how many times? 3 Enter a move (1-Rock, 2 Paper, 3 scissors): 1 Computer selected Paper Computer wins Enter a move (1 Rock, 2 Paper, 3 scissors) 1 Computer selected Scissors User wins Enter a move (1 Rock, 2 Paper, 3 scissors) 1 Computer selected Rock Tie Enter a move (1 Rock, 2 Paper, 3 cissors 1 Computer selected Scissors User wins Game statistics Number of times Rock selected 5 Number of times Paper selected: 1 Number of times Scissors selected

#include <stdio.h>

#include <stdlib.h>

#include <time.h>

int main()

{

int userMove;

int computerMove;

srand(time(NULL)); //put this line after your variable declarations but before other code

printf("This is a rock, paper, and scissor game. \nPlease enter a move(1=Rock, 2 =Paper, 3=Scissors):");

scanf("%d", &userMove);

printf("\n Computer chooses ");

computerMove=1+rand()%3;

if(computerMove==1)

{

printf("Rock!\n");

}

else if(computerMove==2)

{

printf("Paper!\n");

}

else if(computerMove==3)

{

printf("Scissor!\n");

}

else printf("Tie!");

//{

  

if ((userMove==1)&&(computerMove==1))

{

printf("\n Tie!");

}

else if ((userMove==1)&&(computerMove==2))

{ printf("\n Computer Wins!");

}

else if ((userMove==1)&&(computerMove==3))

{ printf("\n User Wins!");

}

else if((userMove==2)&&(computerMove==1))

{ printf("\n User Wins!");

}

else if((userMove==2)&&(computerMove==2))

{ printf("\n Tie!");

}

else if((userMove==2)&&(computerMove==3))

{ printf("\n Computer Wins!");

}

else if((userMove==3)&&(computerMove==1))

{ printf("\n Computer Wins!");

}

else if((userMove==3)&&(computerMove==2))

{ printf("\n User Wins!");

}

else if((userMove==3)&&(computerMove==3))

{ printf("\n Tie!");

}

else

{ printf("You have select an invalid selection.");

  

}

  

}

Answer
Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.

Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.