Question: READ THIS SECTION CAREFULLY For full credit, your code must.... A. Compile without errors. (20 points) B. Run without errors. (20 points) C. Your C




READ THIS SECTION CAREFULLY For full credit, your code must.... A. Compile without errors. (20 points) B. Run without errors. (20 points) C. Your C file must be properly indented. (10 points) D. When run, your program should do the following: 1. Print a prompt (1 point): Do you want to throw (r)ock, (p)aper, or (s)cissors? 2. Read in a character from the user (4 points) a) r indicates the user chose Rock. b) p indicates the user chose Paper. c) s indicates the user chose Scissors 3. If the user enters an invalid character (not r, p, or s), repeat steps 1 and 2. (10 points) 4. Randomly select either rock, paper, or scissors as the computer's choice. (10 points) 5. Print the user's choice (2 points) You threw The chose. is replaced by ROCK, PAPER, OR SCISSORS depending on what the user 6. Print the computer's choice (2 points) The computer threw ! is replaced by ROCK, PAPER, or SCISSORS depending on what the Where the computer threw 7. Update the scores of the user and computer. (5 points) a) Rock beats Scissors, Scissors beats Paper, Paper beats Rock. b) If the computer beat the user, increase the computer's score by 1. c) If the user beat the computer, increase the user's score by 1. d) If it was a tie, the scores remain unchanged. 8. Print the user's score and the computer's score (1 point) YOU: ? COMPUTER: ? a) The first? should be replaced by the user's score. b) The second ? should be replaced by the computer's score. 9. Repeat steps 1-8 until either the user or the computer reaches a score of 3. (10 points) 10. Finally, print the outcome of the game (5 points): a) If the player won, print: You WIN! b) If the computer won, print: You LOSE! Example Program Output When you run your program, you should first see this: Do you want to throw (r)ock, (p)aper, or (s)cissors? If the user enters r, your program should output: You threw ROCK! Then suppose your program randomly selected scissors for the computer. Your program should then output: The computer threw SCISSORS! YOU: 1 COMPUTER: 0 Do you want to throw (r)ock, (p)aper, or (s)cissors? Then if the user enters s and your program randomly selects rock for the computer, your program should output. You threw SCISSORSI The computer threw ROCK! YOU: 1 COMPUTER: 1 Do you want to throw (r) ock, (p)aper, or (s)cissors? Now suppose you enter an invalid input, like x. Your program should output (again): Do you want to throw (r)ock, (p)aper, or (s)cissors? Now suppose you enter p and your program randomly selects paper for the computer, your program should output: You threw PAPERI The computer threw PAPER! YOU: 1 COMPUTERE 1 Do you want to throw (r) ock, (p)aper, or (scissors? Notice the score remains unchanged Let's suppose for the next two rounds you throw scissors and the computer throws paper. Your program should output: You threw SCISSORS! The computer threw PAPER! YOU: 2 COMPUTER: 1 Do you want to throw (r)ock, (p)aper, or (s)cissors? You threw SCISSORS! The computer threw PAPER! YOU: 3 COMPUTER: 1 You WINI Then the program should exit
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
