Using very basic Java programming Write a program that lets the user play the game of Rock, Paper, Scissors against the computer.The program should use an array of Strings with the names of the choices.The program should loop until the human player decides to quit.The game should keep track of how many times the human won, lost, or tied and present those values when the game ends.
import java.util.Random;
import java.util.Scanner;
public class RockPaperScissors {
public final static String ONE = "rock";
public final static String TWO = "paper";
public final static String THREE = "scissors";
static int comCount=0;
static int userCount=0;
public static void main(String[] args) {
String ch = "y";
Scanner sc = new
Scanner(System.in);
while (ch.equalsIgnoreCase("y"))
{
int cch =
getSystemChoice();
int uch =
getPlayerChoice();
displayWinner(cch, uch);
System.out.println("Do you want to continue (Y/N)");
ch =
sc.nextLine();
}
System.out.println("Computer Wons :
"+comCount);
System.out.println("User Wons :
"+userCount);
sc.close();
}
private static int getSystemChoice() {
// generating the random from 1 to
3
int n = new Random().nextInt(3) +
1;
return n;
}
private static int getPlayerChoice() {
// asking the for user input
Scanner sc = new
Scanner(System.in);
System.out.println("Enter user
chouce 1 rock 2 papaer 3 scissors");
return sc.nextInt();
}
private static void displayWinner(int c, int user)
{
// checking winner based on user
and computer choice
if (c == 1 && user ==
3){
System.out.println("Computer wons");
comCount++;
}
else if (c == 3 && user ==
1){
System.out.println("User wons");
userCount++;
}
else if (c == 2 && user ==
1){
System.out.println("Computer wons");
comCount++;
}
else if (c == 1 && user ==
2){
System.out.println("User wons");
userCount++;
}
else
System.out.println("game is tie");
}
}
Using very basic Java programming Write a program that lets the user play the game of...
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...
Java CSC252 Programming II Static Methods, Enums, Constants, Random Rock Paper Scissors Write a program that allows the user to play "Rock, Paper, Scissors". Write the RPS class. All code should be in one file. main() will be part of the RPS class, fairly small, and contain only a loop that asks the user if they want to play "Rock, Paper, Scissors". If they say yes, it calls the static method play() of the RPS class. If not, the program...
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...
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...
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 python: The randrange(min, max) produces a random integer greater than or equal to min and less than max. So randrange(0,3) produces either 0, 1, or 2 Write a program that asks the user to input paper, rock, scissors, or done If they input something else, repeat the question. If they input 'done', exit the game loop. If they input rock, paper, or scissors, have the computer pick a random choice. Write a function that takes two strings, each 'rock', 'paper',...
PLEASE INCLUDE SAW-PROMPTS FOR 2 PLAYERS NAMES(VALIDATE NAMES). SHOW MENU (PLAYER MUST SELECT FROM MENU B4 THE GAME STARTS 1=PLAY GAME, 2=SHOW GAME RULES, 3=SHOW PLAYER STATISTICS, AND 4=EXIT GAME WITH A GOODBYE MESSAGE.) PLAYERS NEED OPTION TO SHOW STATS(IN A DIFFERNT WINDOW-FOR OPTION 3)-GAME SHOULD BE rock, paper, scissor and SAW!! PLEASE USE A JAVA GRAPHICAL USER INTERFACE. MUST HAVE ROCK, PAPER, SCISSORS, AND SAW PLEASE This project requires students to create a design for a “Rock, Paper, Scissors,...
The game lets players know whether they have won, lost, or tied a particular game. Modify the game so the players are told the number of games they have won, lost or tied since the start of game play. Implement this change by adding three variables named $wins, $lost, and $ties to the program's Main Script Logic section, assigning each an initial value of 0. Next, modify the analyze_results method by adding programming logic that increments the values of $wins,...