Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This is in C code. Thank you. Description: This assignment is to write a program to score the paper-rock-scissors game AGAIN. Each of two players

image text in transcribedimage text in transcribed

This is in C code. Thank you.

Description: This assignment is to write a program to score the paper-rock-scissors game AGAIN. Each of two players enters either P, R, or S. The program then announces the winner as well as the basis for determining the winner: "Paper covers rock", "Rock breaks scissors", "Scissors cut paper", or "Draw, nobody wins". The players must be able to enter either upper- or lower-case letters. The primary differences between this daily and daily 10 are that: (1) After you read the player's choice, you will need to create an enumerated type variable to store the value (based on the input). The enumerated type should be called Choice that has three values, ROCK, PAPER, and SCISSORS. For example, if the user enters 'P or 'p', you'll need to create a Choice type variable, e.g., choice1, with a value PAPER choice1 PAPER; Then you'll use the new variable choice1 in your program later (but not input1 any more). This makes it so that the only part of your program that pertains to the player choices that can involve character type variables is the input portion. The rest of your program should always use variables of the enumerated Choice type and the end result should be that your program is easier to read. Also, remember to define the Choice type as a global name as we learned in the class. (2) Use switch statement to rewrite if-else, or nested if-else you used in daily 10. You may write the code entirely with switch-case statement or the combination of switch statement with the nested if-else. Goal: to make your code more readable! Your program output should look the same as before: > run Player-1, please enter your choice

aper, ock, or cissors: Player-2, please enter your choice

aper, ock, or cissors: Player-1 wins! Paper covers rock

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

From Zero To Data Hero With Chatgpt

Authors: Andrew Wu

1st Edition

B0CQRJPXD9, 979-8989523009

More Books

Students also viewed these Databases questions