Access Millions of academic & study documents

A simple program that takes a list of actions (say [ROCK, PAPER, SCI

Content type
User Generated
Showing Page:
1/9
A simple program that takes a list of actions (say [ROCK,
PAPER, SCISSORS] or [BIRD, TIGER, WHALE, KITTEN,
MOUSE] ) that plays like rock, paper, scissors where each
option is beaten by some and beats some consistently.
The program should ask the user for a selection and have
the computer randomly pick one. Then it should determine
the winner. For the above question I want to see how you
tackle problems and possibly how you write code. I\'m
looking for an explanation, high-level, of how solution
program might work to tackle these problems. If you want
to write a outline explanation, that\'s great. If you want to
write some pseudo-code to answer the problems, that\'s
awesome too. If writing full-fledged C++, C# or Java is
easier for you, by all means, please write it all out. We are
interested in how you apply problem solving thinking to
these.
Solution
/* C++ code for playinmg a game of rock paper scissors
between player and computer */
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <string>

Sign up to view the full document!

lock_open Sign Up
Showing Page:
2/9
using namespace std;
int main()
{
// variable to count how many times computer and player
won and display at the end the ties as well
int player = 0;
int computer = 0;
int tie = 0;
char playagain;
while(true)
{
// variables for user choice and computer choice
int userChoice;
int computerChoice;
// taking input from user
cout << \"\ 1.Rock\ 2.Paper\ 3.Scissors\ \" << endl;
cout << \"Enter your choice: \";
cin >> userChoice;
if(userChoice == 1)
cout << \"You chose: \" << \"Rock\" << endl;
else if(userChoice == 2)
cout << \"You chose: \" << \"Paper\" << endl;
else if(userChoice == 3)
cout << \"You chose: \" << \"Scissors\" << endl;
srand(time(NULL));

Sign up to view the full document!

lock_open Sign Up
Showing Page:
3/9

Sign up to view the full document!

lock_open Sign Up
End of Preview - Want to read all 9 pages?
Access Now
Unformatted Attachment Preview
A simple program that takes a list of actions (say [ROCK, PAPER, SCISSORS] or [BIRD, TIGER, WHALE, KITTEN, MOUSE] ) that plays like rock, paper, scissors where each option is beaten by some and beats some consistently. The program should ask the user for a selection and have the computer randomly pick one. Then it should determine the winner. For the above question I want to see how you tackle problems and possibly how you write code. I \'m looking for an explanation, high-level, of how solution program might work to tackle these problems. If you want to write a outline explanation, that \'s great. If you want to write some pseudo-code to answer the problems, that \'s awesome too. If writing full-fledged C++, C# or Java is easier for you, by all means, ple ase write it all out. We are interested in how you apply problem solving thinking to these. Solution /* C++ code for playinmg a game of rock paper scissors between player and computer */ #include #include #include #include #include using namespace std; int main() { // variable to count how many times computer and player won and display at the end the ties as well int player = 0; int computer = 0; int tie = 0; char playagain; while(true) { // variables for user choice and computer choice int userChoice; int computerChoice; // taking input from user cout ...
Purchase document to see full attachment
User generated content is uploaded by users for the purposes of learning and should be used following Studypool's honor code & terms of service.
Studypool
4.7
Indeed
4.5
Sitejabber
4.4