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

Here is the API for a robot library. // moves the robot forward function moveForward(); // turns the robot to the left function rotateLeft(); // turns the robot to the right function rotateRight(); // checks if a robot can move in any direction // direction {string} - the direction to be checked // return {Boolean} - true if the robot can move in that direction, otherwise returns false function canMove(direction); Which code segment will guarantee that the robot makes it to the gray square without hitting a wall or a barrier (black square)

Answers

Answer:

Option (A)

Explanation:

See attachment for options

From the options, the code segment of option (A) answers the question and the explanation is as follows:

I added a second attachment which illustrates the movement

function (solveMaze) {

moveForward(); ---- The robot moves up (to position 1)

moveForward(); ---- The robot moves up (to position 2)

rotateRight(); ---- The robot changes where it faces (however, it is still at position 2)

while(canMove("forward")) { moveForward(); } ---- This is repeated until the robot reaches the end of the grid (i.e. position 3 and 4)

rotateLeft(); ---- The robot changes where it faces (however, it is still at position 4)

moveForward(); ---- The robot moves up to the gray square

Passive devices _____ require any action from the occupants. A. Do not B.Sometimes C.Rarely D.Occasionally

Answers

Answer:

D:

Explanation:

I think, but double check!

Have a nice life and I hope you get full marks on your test/paper/work!

:)

10. Differentiate between equity share & preference share.​

Answers

Answer:

Equity Shares are commonly called Common shares and have both advantages and disadvantages over Preference shares.

Equity shareholders are allowed to vote on company issues while preference shareholders can not.Preference shareholders get paid first between the two in the case that the company liquidates from bankruptcy. Preference shareholders get a fixed dividend that has to be paid before equity share dividends are paid. Preference shareholders can convert their shares to Equity shares but equity shareholders do not have the same courtesy.Preference shares can only be sold back to the company while equity shares can be sold to anybody.

Temperature converter. This program should prompt the user for two arguments, first a decimal number and second, a single letter, either C or F. The decimal represents a temperature, the character represents which system that degree is in (50.0 F would be 50.0 degrees Fahrenheit etc.). This program should take the given number and convert it to a temperature in the other system. The output string format should be degree(s) is equal to degree(s) . Eg. input 0 C would give the string 0.0000 degree(s) C is equal to 32.0000 degree(s) F. You can assume that either F or C will be given for input, no need to account for invalid input.

Answers

Answer:

[tex] \boxed{ \tt{I \: wrote \: the \: program \:with \:( c++)}}[/tex]

Given the mass of an airplane, the amount of forward force produced by its propellers, and the mass of the TWO gliders it is towing (airplane connected to first glider and the first glider is connected to the second glider), calculate the resulting tension on each cable connecting the aircraft and the acceleration of the glider. Vertical forces and air resistance are not considered. . Your program must accept input and produce output that matches exactly to the given executions. Note that the width modifier used for the tension values is calculated as the number of digits in the force input plus six. Example Execution #1 (eleven spaces after colon character for tension output): Enter mass of airplane (kg) -> 15000 Enter mass of glider #1 (kg) -> 5000 Enter mass of glider #2 (kg) -> 4500 Enter force produced by propellers (N) -> 75000 Acceleration: 3.06 m/s^2 -=-=-= Resulting tension on cable #1: Resulting tension on cable #2: 29081.63 Newtons 13775.51 Newtons

Answers

Answer:

Follows are the code to this question:

#include <stdio.h>//header file

int main() //main method  

{

int plane, g1, g2, f;//defining integer variables

float m,a,t1,t2; //defining float variables

printf("Enter mass of airplane (kg)-> ");//print message for input value

scanf("%d", &plane);//input value

printf("Enter mass of glider #1 (kg)-> ");//print message for input value

scanf("%d", &g1);//input value

printf("Enter mass of glider #2 (kg)-> ");//print message for input value

scanf("%d", &g2);//input value

printf("Enter force produced by propellers (N) -> ");//print message for input value

scanf("%d", &f);//input value

m= plane + g1 + g2;//use float variable m to calculate Mass

a=f/m;//use float variable a to calculate Acceleration

printf("\nAcceleration: %.2f m/s^2", a);

printf("\n-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-");//use print method for design

t1 = (g1 + g2) * a;//using the t1 variable to calculate tensions

printf("\nResulting tension on cable #1: %.2f Newtons", t1);//print tension value

t2 = g2 * a;//using the t1 variable to calculate tensions

printf("\nResulting tension on cable #2: %.2f Newtons", t2);//print tension value

printf("\n-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-");//use print method for design

return 0;

}

Output:

Please find the attached file.

Explanation:

In this code four integer variable "plane, g1, g2, and f" and four floating-point variables "m, a, t1, and t2" is declared, in which the integer variable is used for input the value from the user-end.

In the next step, the "m" variable is used, which adds the "plane, g1, and g2" integer value to calculate mass, and in the "a" variable it calculates the acceleration, and in the "t1 and t2" variable it calculates the tension and prints its value.

what are some applications of computer in public administration?​

Answers

Answer:

Explanation:

Embedded Systems.

Windows applications (also called 'Desktop applications')

Web Applications.

Web Services.

Console applications.

List 5 ways by which Artificial intelligence (AI) can be used to drive our business.​

Answers

Answer:

start a website

Explanation:

true


Using the Impress program, you can add multimedia files, including audio, image, and video files, to the presentation
by using
the Insert menu.
the Media menu.
the Edit menu.
the Add menu.
Mark this and return

Answers

Answer:

A. The Insert Menu

Explanation:

:)

Answer:

Edit menu

Explanation:

You are working with a client who wants customers to be able to tap an image and see pricing and availability. As you are building the code in Java, what will you be using?


graphical user interface

icon public use

graphical public use

icon user interface

Answers

Answer:

A. Graphical user interface

Explanation:

In Java the graphical user interface is what manages interaction with images.

Answer: A.)

Explanation:

The answer is A because

I was born to rule the world

And I almost achieved that goal

(Giovanni!)

But my Pokémon, the mighty Mewtwo,

Had more power than I could control

(Giovanni!)

Still he inspired this mechanical marvel,

Which learns and returns each attack

(Giovanni!)

My MechaMew2, the ultimate weapon,

Will tell them Giovanni is back!

There'll be world domination,

Complete obliteration

Of all who now defy me.

Let the universe prepare,

Good Pokémon beware,

You fools shall not deny me!

Now go, go, go, go!

It will all be mine,

Power so divine

I'll tell the sun to shine

On only me!

It will all be mine,

Till the end of time

When this perfect crime

Makes history

Team Rocket! This is our destiny!

Listen up, you scheming fools,

No excuses, and no more lies.

(Giovanni!)

You've heard my most ingenious plan,

I demand the ultimate prize

(Giovanni!)

Now bring me the yellow Pokémon

And bear witness as I speak

(Giovanni!)

I shall possess the awesome power

In Pikachu's rosy cheeks!

There'll be world domination,

Complete obliteration

Of all who now defy me.

Let the universe prepare,

Good Pokémon beware,

You fools shall not deny me!

Now go, go, go, go!

It will all be mine,

Power so divine

I'll tell the sun to shine

On only me!

It will all be mine,

Till the end of time

When this perfect crime

Makes history

Team Rocket! This is our destiny!

To protect the world from devastation

To unite all peoples within our nation

To denounce the evils of truth and love

To extend our reach to the stars above

Jessie!

James!

There'll be total devastation,

Pure annihilation

Or absolute surrender.

I'll have limitless power,

This is our finest hour

Now go, go, go, go!

instances of how computer viruses are spread​

Answers

Answer:

downloading apps from unsafe websites

Explanation:

some viruses have been embeded into this sites and when u download a file or an app the virus downloades with it

Answer:

Computer viruses can spread through the following media :

By opening an infected e-mail attachment,By downloading an infected program from the internet,By using infected floppy disk,pen drives and CDs,By transferring an infected program over a network and executing it.

For our homework we have to listen__ a podcast​

Answers

Answer:

For our homework we have to listen to a podcast

Other Questions
Help me I will mark you brainelest ASAP plz fyi for the back side you can use brainly its easy but i have allat more work to do plz ill make u brainliest!! what is HARITHA HARAM? in telagana how is the relation of spouses married at early age I need help with this ASAP!!!! What is one thing Isabel remembers about Abuelita from what Esperanza has told her, and she asks her about when she first meets her? What geometric shape is the carbon dioxide molecule? The Lewis structure for CO2 contains two double bonds. The Richter scale ranges from 1 to 10 in increments of tenths and measures the amount of energy released by an earthquake, not the amount of damage or the effect on people. How many earthquakes of magnitude 4.0 does it take to release the same amount of energy released by one earthquake of magnitude 8.0? (Show your work) write a description about thunder what is the answer of (ab) Manuel paid off 88% of his debt. He originally owed $$$1950. How much does Manuel owe now? There is a line that includes the point (9, 1) and has a slope of -8. What is its equation inpoint-slope form? Plsssss help Im being timed-Also you cannot remove the commas thats already in their!!!! i need help pleaseeeeeee dose the following table of points represent a function Is energy absorbed or released during cellular respiration? Absorbed Released What did the effects of the droughts in the early 1900s and the 1915 boll weevil infestation show about Georgia? 1b. $1/61/3Lin said the value of this expression is $1/6. Is she correct? Explain or show your reasoning to prove your answerPLS ANSWER CORRECTLY Performance Plastics Company (PPC) has been operating for three years. The beginning account balances are Cash $35,000 Accounts Receivable 5,000 Inventory 40,000 Supplies 5,000 Notes Receivable (due in three years) 2,000 Equipment 80,000 Buildings 120,000 Land 30,000 Accounts Payable 37,000 Notes Payable (due in three years) 80,000 Common Stock 150,000 Retained Earnings 50,000 During the year, the company had the following summarized activities: a. Purchased equipment that cost $21,000; paid $5,000 cash and signed a two-year note for the balance. b. Issued an additional 2,000 shares of common stock for $20,000 cash. c. Borrowed $50,000 cash from a local bank, payable June 30, in two years. d. Purchased supplies for $4,000 cash. e. Built an addition to the factory buildings for $41,000; paid $12,000 in cash and signed a three-year note for the balance. f. Hired a new president to start January 1 of next year. The contract was for $95,000 for each full year worked.Required: Analyze transactions to determine their effects on the accounting equation. Se necesitan 30kg al dia para alimentar a las gallinas y alos gallos. Se tiene un gallo por cada 5 gallinas y se sabe que una gallina come una media de 400g, el doble que un gallo