Help a brother out


Write a java program with these specifications.





playRps – This method plays 24 rounds of rps and returns the total points earned. For each of the 24 rounds, player1’s hand
gesture will be based on calling the nextInt method of the given Random object. If the next integer is even, player1 will play
rock. If it is odd, player1 will play paper. Player1 never plays scissors. Player2 will play rock in the first round, paper in the
second round, scissors in the third round, and repeat the cycle starting with rock again in the fourth round. The method will sum
the return values for the 24 calls to rps and return the total. Note, since an invalid input is never passed in to an rps call using
playRps, your return value should always be a non-negative number.

Answers

Answer 1

Answer:

import java.util.*;  

class Main {

 private enum RPS { Rock, Paper, Scissors };

 private static RPS[] options = { RPS.Rock, RPS.Paper, RPS.Scissors };

 private static String[] names = {"Rock", "Paper", "Scissors"};

 // Return 1 if player 1 beats player 2, 0 otherwise

 static public int rps( RPS p1, RPS p2 ) {

   if (p1 == RPS.Rock && p2 == RPS.Scissors) return 1;

   if (p1 == RPS.Scissors && p2 == RPS.Paper) return 1;

   if (p1 == RPS.Paper && p2 == RPS.Rock) return 1;

   return 0;

 }

 static public int playRps() {

   Random rnd = new Random();      

   int totalPoints = 0;

   

   for(int round = 0; round < 24; round++) {

     int randomNumber = rnd.nextInt(2);  

     RPS player1 = options[randomNumber];      

     RPS player2 = options[round%3];

     String name1 = names[randomNumber];

     String name2 = names[round%3];

     int score = rps(player1, player2);

     if (player1 == player2) {

       System.out.printf("%d. Both players %s. Draw.\n",  round+1, name1);

     } else if (score == 0) {

       System.out.printf("%d. %s does not beat %s, player 1 loses.\n",  round+1, name1, name2);

     } else {

       System.out.printf("%d. %s beats %s, player 1 wins.\n", round+1, name1, name2);

     }      

     totalPoints += score;

   }

   return totalPoints;

 }

 public static void main(String[] args) {

   System.out.println("Playing RPS.");

   int total = playRps();

   System.out.printf("Player 1 earned %d points.\n", total);

 }

}


Related Questions

ERIC'S Company sells cement at 30.0 Ghana Cedis per bag. The company

however gives discount of 15% for customers that buy 100 or more bags, and 0% for

customers that buy less than 100 bags.
Write a pseudo code and present a flowchart that

will display the discount percentage when the quantity of bags purchased is entered.​

Answers

Answer:

The pseudocode is as follows:

Input Quantity

Discount = 0%

If Quantity >= 100:

    Discount = 15%

Print Discount

See attachment for flowchart

Explanation:

This line gets the quantity from the user

Input Quantity

This line initializes the discount to 0%

Discount = 0%

This checks if quantity is more than or equal to 100

If Quantity >= 100:

If yes, discount is set to 15%

    Discount = 15%

This prints the discount percentage

Print Discount

See attachment for flowchart

BitTorrent, a P2P protocol for file distribution, depends on a centralized resource allocation mechanism through which peers are able to maximize their download rates.
True or False?

Answers

Answer:

yes. it is true. mark as brainlest

System software includes all of the following except

Answers

Answer:

System software includes all of the following except Browsers.

Explanation:

I just know

System software includes all the following except Browsers. There are the based on the system software are the important parts.

What is software?

Software is the term for the intangible. The software is the most significant aspect. Software is a collection of rules, data, or algorithms used to run machines and perform certain tasks. Apps, scripts, and programs that run on a mobile device are referred to as software.

According to the system software, are the based on the operating system, management system, are the networking, translators, software utilities, are the networking. They are the browsers are not the used of the software, the significant components are the configuration.

As a result, the system software includes all the following except Browsers.

Learn more about on software, here:

https://brainly.com/question/985406

#SPJ2

Other Questions
Can anybody help me complete this worksheet please? I will mark you as brainliest and will be very happy! Assuming the speed of sound is 340 m/s, what is the most likely speed of the jet shown below? can someone help me please Can somebody please help?? Quik Call charges 18 per minute for long-distance calls. Econo Phone totals your phone usage each month and rounds the number of minutes up to the nearest 15 minutes. It then charges $7.90 per hour of phone usage, dividing this charge into 15-minute segments if you used less than a full hour. If your office makes 5 hours 3 minutes worth of calls this month using the company with the lower price, how much will these calls cost? Find the solution to the system of equations given below:x=-4-5x-4y=16PLS HELP j < 0.65 The variable in the inequality is . A I couldn't believe .... it took them to processmy application.la how much(b) how long(c) how many(d) where HELPS ASAP PLZQuestion: If hotdogs are sold in packages of 10 and buns are sold in packages of 8, how many packages of each would you need to buy to get an equal number of hotdogs and buns? 3. Darwin surmised that all life on Earth was connected, like branches on a tree of life. What would the trunk of this tree represent? What is the ratio of x to y?5x = 6y Len has 3 strips of construction paper. Each strip is the same size and a different color-red, yellow, and pink. He tapes the strips together to make a rectangle. Then Len divides the rectangle into sixths so that each sixth is one color. What fraction other than 1/3 names the part of the rectangle that is red? Is the line through points P(2,-9) and Q(6, -13) perpendicular to the line through points R(5,-1) andS(1,-5)? lol what.. its kinda bad tho what is the difference between a food chain and a food web? isn't this app supposed to be like a school app why are people commenting about their political decision and using foul language? i just wanted to say this if you answer you can get 10 points but you don't have to say anything about the question. Lisa goes out to eat with her family and spends 42.50. she gives the waiter 15% tip .how much money does she spend in total ? A science classroom has 5 turtles and 7 frogs. What is the ratio of FROGS to TOTAL animals?5:77:125:12 plsssss help its easy!!!!!(one question)wrong answer for points=banned Volume of a cylinder the radius Is 5ft the height is 10ft