Question
use C++
Lets make a gamel The user picks rock, paper, or scissors. The computer randomly picks rock, paper, or scissors as well. The
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Required c++ program will be:

#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <string>
using namespace std;
int main()
{
   do{
       std::string userChoice;
       int computer;
       cout << "Choose one of them (All lowecase) rock, paper, scissors" << endl;
       cin >> userChoice;
       cout << "You entered: " << userChoice << endl;
       srand(time(NULL));
       computer = rand() % 10 + 1; //this will generate random option for computer
       //Computer "brain"
       if (computer <= 3)
           cout << "Computer chose: Rock" << endl;
       else if (computer <= 6)
           cout << "Computer chose: Paper" << endl;
       else if (computer >= 7)
           cout << "Computer chose: Scissors" << endl;
       //Determines winner
       //Rock
       if (userChoice == "rock" && computer <= 3)
           cout << "It's a tie!" << endl;
       else if (userChoice == "rock" && computer <= 6)
           cout << "You lose!" << endl;
       else if (userChoice == "rock" && computer >= 7)
           cout << "You win!" << endl;
       //Paper
       if (userChoice == "paper" && computer <= 3)
           cout << "You win!" << endl;
       else if (userChoice == "paper" && computer <= 6)
           cout << "It's a tie!" << endl;
       else if (userChoice == "paper" && computer >= 7)
           cout << "You lose!" << endl;
       //Scissors
       if (userChoice == "scissors" && computer <= 3)
           cout << "You lose!" << endl;
       else if (userChoice == "scissors" && computer <= 6)
           cout << "You win!" << endl;
       else if (userChoice == "scissors" && computer >= 7)
           cout << "It's a tie!" << endl;
   } while (cin.get()); // this condition never be false so to finish the game give invalid input
   cin.get();
   return 0;
}
Screenshot of program output will be:

Output /tmp/UtFURhoHsp.o Choose one of them (All lowecase) rock, paper, scissors rock You entered: rock Computer chose: Rock

PLEASE UPVOTE THE ANSWER AND FEEL FREE TO ASK YOUR DOUBTS IN COMMENT SECTION

Add a comment
Know the answer?
Add Answer to:
use C++ Let's make a gamel The user picks rock, paper, or scissors. The computer randomly...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • java pls Rock Paper Scissors Lizard Spock Rock Paper Scissors Lizard Spock is a variation of...

    java pls Rock Paper Scissors Lizard Spock Rock Paper Scissors Lizard Spock is a variation of the common game Rock Paper Scissors that is often used to pass time (or sometimes to make decisions.) The rules of the game are outlined below: • • Scissors cuts Paper Paper covers Rock Rock crushes Lizard Lizard poisons Spock Spock smashes Scissors Scissors decapitates Lizard Lizard eats Paper Paper disproves Spock Spock vaporizes Rock Rock crushes Scissors Write a program that simulates the...

  • In this problem, you’ll play a simple rock, paper, scissors game. First, you’ll ask the user...

    In this problem, you’ll play a simple rock, paper, scissors game. First, you’ll ask the user to pick rock, paper, or scissors. Then, you’ll have the computer randomly choose one of the options. After that, print out the winner! You should keep playing the game until the user hits enter. Note: You’ll need to implement a method called String getWinner(String user, String computer). Luckily, you just wrote that in an earlier program! Here is a sample run of the program....

  • JAVA Beginnings of a paper-rock-scissors game. Paper-rock-scissors is a game often used to make decisions. There...

    JAVA Beginnings of a paper-rock-scissors game. Paper-rock-scissors is a game often used to make decisions. There are two players. Each player secretly chooses either, paper, rock or scissors. At the count of three, each player reveals what they have chosen. The winner of the game is determined this way: paper beats rock (because paper covers rock) rock beats scissors (because rock crushes scissors) scissors beat paper (because scissors cut paper) If the two players choose the same item, it is...

  • For this week’s assignment, we will be recreating the Rock, Paper, Scissors program using Object-...

    For this week’s assignment, we will be recreating the Rock, Paper, Scissors program using Object-Oriented Programming. You will be working with me on a team to build the program. I have already written my part of the program, and the Game.java file is attached. Your task will be to write a RockPaperScissors class that contains the following methods: getUserChoice: Has the user choose Rock, Paper, or Scissors. After validating the input, the method returns a String containing the user choice....

  • It's writing a simple rock paper scissors game strictly following the instructions. INSTRUCTIONS: If the user...

    It's writing a simple rock paper scissors game strictly following the instructions. INSTRUCTIONS: If the user selects 'p': 1. First the program should call a function named getComputerChoice to get the computer's choice in the game. The getComputerChoice function should generate a random number between 1 and 3. If the random number is 1 the computer has chosen Rock, if the random number is 2 the user has chosen Paper, and if the random number is 3 the computer has...

  • Objective: Write a program that simulates a game of rock, paper, scissors between a human and...

    Objective: Write a program that simulates a game of rock, paper, scissors between a human and the computer in best 2 out of 3 rounds. Requirements: . The player can enter either "rock", "paper", or "scissors'". o If the player enters anything other than that the computer automatically gets a point . The computer randomly selects one of the gestures o Use the Random type to make this easier o Also make sure you import java.util.Random o You can use...

  • Write a Python program (rock_paper_scissors.py) that allows two players play the game rock paper scissors. Remember...

    Write a Python program (rock_paper_scissors.py) that allows two players play the game rock paper scissors. Remember the rules: 1. Rock beats scissors 2. Scissors beats paper 3. Paper beats rock The program should ask the users for their names, then ask them for their picks (rock, paper or scissors). After that, the program should print the winner's name. Note, the players may pick the same thing, in this case the program should say it's tie. when the user input an...

  • You are asked to implement scissors-rock-paper game where the players are a computer and a user....

    You are asked to implement scissors-rock-paper game where the players are a computer and a user. The player that wins 3 hands successively is the winner of the game. Your program should prompt the user with a message at the beginning of each hand to enter one of scissors, rock or paper. If the user's entry is not valid, i.e. entry is neither scissors, rock, nor paper, your program throws a message to the user to enter a valid entry...

  • This program should be in c++. Rock Paper Scissors: This game is played by children and...

    This program should be in c++. Rock Paper Scissors: This game is played by children and adults and is popular all over the world. Apart from being a game played to pass time, the game is usually played in situations where something has to be chosen. It is similar in that way to other games like flipping the coin, throwing dice or drawing straws. There is no room for cheating or for knowing what the other person is going to...

  • IN JAVA. Write a program that lets the user play the game of Rock, Paper, Scissors...

    IN JAVA. Write a program that lets the user play the game of Rock, Paper, Scissors against the computer. The program should work as follows. When the program begins, a random number in the range of 1 through 3 is generated. If the number is 1, then the computer has chosen rock. If the number is 2, then the computer has chosen paper. If the number is 3, then the computer has chosen scissors. Don’t display the computer’s choice yet....

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT