Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a C program that implements the game of Rock, Paper, Scissors that allows

ID: 639713 • Letter: W

Question

Write a C program that implements the game of Rock, Paper, Scissors that allows two users to play. Your
program must follow the specifications given above to earn full credit. That is, your program must define and
use at least the specified functions. (The names of functions and variables do not have to be exactly the same.)
The output of the program must conform exactly to the following example runs (there are 4 separate runs shown;
user input shown in bold). Note there is no blank line between the program heading and the user input prompts
and a blank line before the first line of output. And as usual, there must be a newline after the last line of output.

Explanation / Answer

main: ( # rock/paper/scissors game # # counts of the number of times the player has chosen each move # # we initialise each to 1 so that the total isn't zero when we are # # choosing the computer's first move (as in the Ada version) # INT r count := 1; INT p count := 1; INT s count := 1; # counts of how many games the player and computer have won # INT player count := 0; INT computer count := 0; print( ( "rock/paper/scissors", newline, newline ) ); WHILE CHAR player move; # get the players move - r => rock # # p => paper # # s => scissors # # q => quit # WHILE print( ( "Please enter your move (r/p/s) or q to quit: " ) ); readf( ( $ a $, player move ) ); read( ( newline ) ); ( player move /= "r" AND player move /= "p" AND player move /= "s" AND player move /= "q" ) DO print( ( "Unrecognised move", newline ) ) OD; # continue playing until the player chooses quit # player move /= "q" DO # decide the computer's move based on the player's history # CHAR computer move; INT move count = r count + p count + s count; # predict player will play rock if the random number # # is in the range 0 .. rock / total # # predict player will play paper if the random number # # is in the range rock / total .. ( rock + paper ) / total # # predict player will play scissors otherwise # REAL r limit = r count / move count; REAL p limit = r limit + ( p count / move count ); REAL random move = next random; IF random move
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote