1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
geniusboy [140]
3 years ago
14

You are to write a program that will simulate a game of Rock, Paper, Scissors. One of the two players will be the computer. The

program will start by asking how many winning rounds are needed to win the game. Each round will consist of you asking the user to pick between rock, paper, and scissors. Internally you will get the computer's choice by using a random number. Rock beats Scissors, Paper beats Rock, and Scissors beats Paper. You will report the win, loss, or tie and continue with another round. Repeating until either the user or the computer has won the correct number of times first. Please output what the user and computer's choice is each time and give a running score total as the game goes on. Each of these programs must be done in a separate file. Name them.
Computers and Technology
1 answer:
Ipatiy [6.2K]3 years ago
6 0

Answer:

The code is written in the explanation.

Explanation:

the code is the following:

import java.util.*;

class Game{

}

public class Main

{

static scanner in = new Scanner(System.in);

public static final String Rock = "Rock";

public static final String Paper = "Paper";

public static final String Scissors = "Scissors";

/*Get computer's move using Random

class nextInt() method */  

public static string getcomputermove()

{

string computermove;

Random random = new Random();

int input = random.nextInt(3)+1;

if (input == 1)

computermove = Main.Rock;

else if(input == 2)

computermove = Main.Paper;

else

computermove = Main.Scissors;

System.out.println("computer move is: " + computermove);

System.out.println();

return computermove;

}

/* get player's move using scanner

class */

public static String getplayermove()

{

String input = in.next();

String playermove = input.toUpperCase();

System.out.println("player move is: "+ playermove);

return playermove;

}

public static void main(String args[])

{

 

System.out.println("welcome to rock, paper, scissors");

System.out.println("enter number of winning rounds");

int r=in.nextInt();

int playerScore=0;

int computerScore=0;

while(playerScore!=r && computerScore!=r){

System.out.println("enter any one of the following inputs: ");

System.out.println("Rock");

System.out.println("Paper");

System.out.println("Scissors");

System.out.println();  

String playerMove = Main.getplayermove();

String computerMove = Main.getcomputermove();  

//rules of the game applied:

/*if both playermove and computermove

produces the same selection, then

game is a tie*/

if (playermove.equals(computermove))

System.out.println("Game is tie");

// if playermove is Rock  

else if (playerMove.equals(Main.Rock))

if(computerMove.equals(Main.Paper)){

System.out.println("computer wins");

computerscore=1;

}else{

System.out.println("player wins");

playerscore=1;

}

// if playermove is Paper

else if (playermove.equals(Main.Paper)){

if(computermove.equals(Main.Scissors)){

System.out.println("computer wins");

computerscore=1;

}else{

System.out.println("player wins");

playerscore=1;

}

}

// if playerMove is Scissors

else{

if(computermove.equals(Main.Rock)){

System.out.println("computer wins");

computerscore=1;

}else{

System.out.println("player wins");

playerscore=1;

}

}

System.out.println("After the round, the computer score is:"+computerscore+" and the player score is:"+playerscore);

}

if(computerscore==r){

System.out.println("You lose, computer wins");

}else{

System.out.println("You Won");

}

}

}

You might be interested in
Self contained sequences of actions to be performed are?
Firlakuza [10]

Answer:

Self contained sequences of actions to be performed are algorithms. - b

6 0
3 years ago
Advantages of e commerce
Sloan [31]

Answer:

A Larger Market

Customer Insights Through Tracking And Analytics

Fast Response To Consumer Trends And Market Demand

Lower Cost

More Opportunities To "Sell"

Personalized Messaging

Hope this helps!

4 0
4 years ago
The expression that is tested by a switch statement must have a(n) __________ value.
Hitman42 [59]

The answer is relational.

6 0
4 years ago
PLEASE HELP PROGRAMMING WILL GIVE BRAINLIEST
DaniilM [7]

Answer:

1. would be B.

2. would be D

3. May I ask if it can be multiple answers?

Explanation:

1. In coding a if statement has to follow if something is true or not. If we are talking about a if and then statement it will skip that block and move to the next block of the "then" part of the "if then" Statement if the first part is reported false

2. This is a easy one, so it has to be either a 3.25 GPA or higher or they have to have either 100 hours or more.

3. waiting for a comment back :)

4 0
4 years ago
Rest or take a break every __ minutes when typing. Please help!
Talja [164]
Maybe like 3-5 I think im right
3 0
4 years ago
Read 2 more answers
Other questions:
  • Please help will mark brainiest
    8·1 answer
  • They begin beating it with a hose to find out what it really means. How does the figurative language in this excerpt reveal Coll
    9·2 answers
  • Wap-enabled devices require a ________, a special web browser that has all the features of computer-based browsers but is simpli
    11·1 answer
  • As part of the systems engineering development team, use IDEF0 to develop a functional architecture. The functional architecture
    13·1 answer
  • Help me pls, thank you
    12·2 answers
  • Can someone please give me timetable managment system with data structures in java?
    11·2 answers
  • Which is a benefit of peer-to-peer networking?
    12·1 answer
  • Please help me plss! PLS​
    8·2 answers
  • Is majority intent determined by how many times the same type of result is shown on the search engine result page?
    6·1 answer
  • Complete the following sentence by choosing the best answer from the options listed below.
    11·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!