Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a program to score the paper-rock-scissors game. Each of two players enters either P, R, or S. The program then announces the winner as

image text in transcribedWrite a program to score the paper-rock-scissors game. 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. If an invalid choice is entered, the player should be permitted to re-enter his choice immediately (before the other player is given a chance to enter their value). The program must allow the players to continue playing as long as desired by asking them after each game if they would like to play again. For this assignment you MUST use a function to get the input value for the players choice. The function MUST return an enumerated type called Choice that has three values, ROCK, PAPER, and SCISSORS. This makes it so that the only part of your program that pertains to the player choices that can involve character 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.

ayer-1 it is your turn Please enter your choice (plaper, (r)ock. or (s cissors: why do not underst ounothunderstander. m sorry (r)ock. (seissors: leas erent er or m sorry ease enter your choice (p)aper, (r)ock, or (s)cissors: Paper! Player-2 1t is your turn Please enter Player-1 winsPaper covers rock choice (p)aper. (r)ock, or (s)cissors: r you wish to cont inue? (y): y ayer-1 it is your turn! Please enter your choice (p)aper, (r)ock, or (s)eissors:s Player-2 it is your turn Please enter Player-2 wins Do you wish to cont inue? yn): Press any key to continue - ice, (p)aper, (r)ock, or (s)cissors: ROCK on cissors 0

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

Database Administrator Limited Edition

Authors: Martif Way

1st Edition

B0CGG89N8Z

More Books

Students also viewed these Databases questions

Question

Discuss the techniques of sales forecasting.

Answered: 1 week ago

Question

Write short notes on Marketing mix.

Answered: 1 week ago

Question

Analyse the process of new product of development.

Answered: 1 week ago

Question

1. Which position would you take?

Answered: 1 week ago