Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

c++ rock paper scissors game Algorithm: programme - Generate three random numbers (0, 1, or 2) - Save the three numbers in an array called:

c++

rock paper scissors game

Algorithm: programme

- Generate three random numbers (0, 1, or 2)

- Save the three numbers in an array called: int compplay[3]

-- Or ... if number is 0, save an 'R' in: char compplay[3]

-- ...... if number is 1, save a 'P,

-- ...... if number is 2, save a 'S'

-- Or ... you can use enumerated types

-Set a flag to 1 (later, if user wants to quit, set it to 0)

-Have a for loop that loops 3 times (0-2) unless user wants to quit

-- Have user1 enter R for rock, P for paper, or S for scissors

-- If the user entered an R and complay[0] is an R, then you have a tie

-- else if the user entered an R and complay[0] is a P then user loses

-- else if the user entered an R and complay[0] is an S then user wins

--- Ask user if they want to keep playing. If it's an n or N, then

use break to get out of loop

The loop should now repeat and you do this again comparing to complay[1], etc...

-Thank user for playing when they are done with their three attempts.

HERE are the rules which determines who wins:

Rock beats scissors

Paper beats rock

Scissors beats paper

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 Concepts

Authors: David Kroenke, David J. Auer

3rd Edition

0131986252, 978-0131986251

More Books

Students also viewed these Databases questions