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 be able to record the score for number of wins for both players. Also, when you change your move, the application must clear out the current win/lose message and the computer's move.
The following codes will create one number randomly from 1, 2 or 3 and assign it to the variable num.
int num = 0;
Random rnd = new Random();
num = rnd.Next(1, 4);
using System;
namespace Rextester
{
public class Program
{
public int playGame(int playerChoice, int computerChoice)
{
int ans = -2;
switch(playerChoice)
{
// if player choice is scissor
case 0 :
// if computer choose Rock
if(computerChoice == 1)
ans = 0;
// if computer choose Paper
else if(computerChoice == 2)
ans = 1;
// if computer choose Scissor
else
ans = -1;
break;
// if player choice is Rock
case 1 :
// if computer choose Paper
if(computerChoice == 2)
ans = 0;
// if computer choose Scissor
else if(computerChoice == 0)
ans = 1;
// if computer choose Rock
else
ans = -1;
break;
// if player choice is Paper
case 2 :
// if computer choose Rock
if(computerChoice == 1)
ans = 1;
// if computer choose Scissor
else if(computerChoice == 0)
ans = 0;
// if computer choose Paper
else
ans = -1;
break;
//default : // for invalid choice
// ans = -2;
}
return ans;
}
public static void Main(string[] args)
{
Program ob = new Program();
int i;
// create a Rando object
Random rand = new Random();
int playerPoints = 0, computerPoints = 0;
Console.WriteLine("Welcome to the rock paper scissors game!\n\n");
// generate random number in range 0 to 2
int computerChoice = rand.Next(0, 3);
int playerChoice;
// infinite loop
while(true)
{
Console.WriteLine("Enter either \"rock\", \"paper\", or \"scissors\" to compete\n");
String pc = Console.ReadLine();
if(String.Compare(pc, "scissors") == 0)
{
playerChoice = 0;
break;
}
else if(String.Compare(pc, "rock") == 0)
{
playerChoice = 1;
break;
}
else if(String.Compare(pc, "paper") == 0)
{
playerChoice = 2;
break;
}
else
Console.WriteLine("Error! Please enter a valid choice.\n\n");
}
Console.WriteLine("The computer picked ");
if(computerChoice == 0)
Console.WriteLine("scissor\n");
else if(computerChoice == 1)
Console.WriteLine("rock\n");
else
Console.WriteLine("paper\n");
int result = ob.playGame(playerChoice, computerChoice);
if(result == 1)
{
Console.WriteLine("You Won!\n");
playerPoints++;
}
else if(result == 0)
{
Console.WriteLine("You Loose!\n");
computerPoints++;
}
else if(result == -1)
Console.WriteLine("It's a draw\n");
else
Console.WriteLine("Error!!\n");
}
}
}
Sample Output

Write a C# program that allows one user to play Rock-Paper-Scissors with computer. The user will...
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: When the program begins, a random number between 1 and 3 is generated. If the number is 1, the computer has chosen rock. If the number is 2, the computer has chosen paper. If the number is 3, the computer has chosen scissors. Don't display the computer's choice yet. Use a menu to display...
C++ Write a program that plays the rock, paper, scissors game. Rock beats scissors; scissors beats paper; paper beats rock. You must use these specific functions in your program. These are the prototypes: char generateP2toss(); int checkThrow(char, char); void printStatistics(int, int, int, int); void finalStatistics(int, int, int, int); void welcome(); Notes on these functions: generateP2toss() will generate the computer's toss (the computer is player2). It returns either an "r", "p", or "s/" checkThrow(char char) will check the throw by passing...
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 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...
Write a program in python that lets the user play the game 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. 2 corresponds to paper, and 3 corresponds to scissors. To set up the random number library, write the following at the top of your code: import random random.seed(300) Use...
(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 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...
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 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....
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...