C++
Part 2: Rock Paper Scissors Game
Write a program that lets the user play this game against the computer. The program should work as follows:
Divide program into functions to perform each major task. You should have at least 4 functions.
Feel free to ask any doubts and give feedback!
The code cotains comments to help you understand
OUTPUT:
CODE:
#include<iostream>
#include<stdlib.h>
#include<time.h>
using namespace std;
int main()
{
//set current time as random seed
srand(time(0));
//infinite loop
while(1)
{
//generate a ranom number using rand()
//rand()%(3-1+1) returns a random number between 0 and 2
//adding 1 will give us desired random number
//cc is computer's choice
int cc=(rand()%(3-1+1))+1;
//enter user's choice
int uc;
cout<<"Enter rock,paper or scissor(1,2,3)\n";
cin>>uc;
//case 1
if(cc==1 && uc==3)
{
cout<<"Compuer won\n";
}
else if(uc==1 && cc==3)
{
cout<<"You won!\n";
}
//case 2
else if(cc==3 && uc==2)
{
cout<<"Compuer won\n";
}
else if(uc==3 && cc==2)
{
cout<<"You won!\n";
}
//case 3
else if(cc==2 && uc==1)
{
cout<<"Compuer won\n";
}
else if(uc==2 && cc==1)
{
cout<<"You won!\n";
}
//last case
else if(uc==cc)
{
//dont break from the loop if uc=cc
continue;
}
else
{
//nothing
}
//break if everything went as expected
break;
}
return 0;
}
C++ Part 2: Rock Paper Scissors Game Write a program that lets the user play this...
In python language Write a program that lets the user play the game of Rock, Paper, Scissors against the computer. The program should work as follows: 1. When the program begins, a random number in the range of 1 and 3 is generated. 1 = Computer has chosen Rock 2 = Computer has chosen Paper 3 = Computer has chosen Scissors (Dont display the computer's choice yet) 2. The user enters his or her choice of “Rock”, “Paper", “Scissors" at...
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....
(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. The...
In JAVA Chapter 5Assignment(Rock, Paper, Scissors)–20pointsYour goal is towrite a program that lets the user play the game of Rock, Paper, Scissors against the computer.Your program should have the following: •Make the name of the project RockPaperScissors•Write a method that generates a random number in the range of 1 through 3. The randomly generated number will determine if the computer chooses rock, paper, or scissors. If the number is 1, then the computer has chosen rock. If the number is...
Write a Python program (using python 3.7.2) that lets the user play the game of Rock, Paper, Scissors against the computer. The program should work as follows. 1. 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...
C++ 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...
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...
Write a C# program that allows one user to play Rock-Paper-Scissors with computer. The user will pick a move (Rock Paper Scissors) from 3 radio buttons and click the play button to play the game. The application will use random number generator to pick a move for the computer. Then, the application display the computer's move and also display whether you won or lost the game, or the game is tie if both moves are the same. The application must...
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 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...