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
eduard
3 years ago
15

Same rule: If both players spend the same number of coins, player 2 gains 1 coin. Off-by-one rule: If the players do not spend t

he same number of coins and the positive difference between the number of coins spent by the two players is 1, player 2 is awarded 1 coin. Off-by-two rule: If the players do not spend the same number of coins and the positive difference between the number of coins spent by the two players is 2, player 1 is awarded 2 coins. The following is an example of a game played with a starting value of 10 coins and a game length of 5 rounds
Engineering
1 answer:
Galina-37 [17]3 years ago
3 0

Answer:

Check the explanation

Explanation:

1 -

public int getPlayer2Move(int round)

{

  int result = 0;

 

  //If round is divided by 3

  if(round%3 == 0) {

      result= 3;

  }

  //if round is not divided by 3 and is divided by 2

  else if(round%3 != 0 && round%2 == 0) {

      result = 2;

  }

  //if round is not divided by 3 or 2

  else {

      result = 1;

  }

 

  return result;

}

2-

public void playGame()

{

 

  //Initializing player 1 coins

  int player1Coins = startingCoins;

 

  //Initializing player 2 coins

  int player2Coins = startingCoins;

 

 

  for ( int round = 1 ; round <= maxRounds ; round++) {

     

      //if the player 1 or player 2 coins are less than 3

      if(player1Coins < 3 || player2Coins < 3) {

          break;

      }

     

      //The number of coins player 1 spends

      int player1Spends = getPlayer1Move();

     

      //The number of coins player 2 spends

      int player2Spends = getPlayer2Move(round);

     

      //Remaining coins of player 1

      player1Coins -= player1Spends;

     

      //Remaining coins of player 2

      player2Coins -= player2Spends;

     

      //If player 2 spends the same number of coins as player 2 spends

      if ( player1Spends == player2Spends) {

          player2Coins += 1;

          continue;

      }

     

      //positive difference between the number of coins spent by the two players

      int difference = Math.abs(player1Spends - player2Spends) ;

     

      //if difference is 1

      if( difference == 1) {

          player2Coins += 1;

          continue;

      }

     

      //If difference is 2

      if(difference == 2) {

          player1Coins += 2;

          continue;

      }

     

     

  }

 

  // At the end of the game

  //If player 1 coins is equal to player two coins

  if(player1Coins == player2Coins) {

      System.out.println("tie game");

  }

  //If player 1 coins are greater than player 2 coins

  else if(player1Coins > player2Coins) {

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

  }

  //If player 2 coins is grater than player 2 coins

  else if(player1Coins < player2Coins) {

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

  }

}

You might be interested in
Can anyone tell me what rock this is?
Oksi-84 [34.3K]

Answer: answer is B

Explanation:

8 0
3 years ago
Read 2 more answers
A coral reef is in danger of being destroyed by a seaside construction project. Which of the following best relates to how an en
Wewaii [24]

Answer:Bio team

Explanation:

4 0
3 years ago
Gaining unauthorized access to a computer's data is called (5 points)
yanalaym [24]
Hacking is correcttttttttt
6 0
3 years ago
Explain the term electric current as used in engineering principles​
vodomira [7]

Answer:

<em>Electric current is the movement of electrons through a wire. Electric current is measured in amperes (amps) and refers to the number of charges that move through the wire per second. If we want current to flow directly from one point to another, we should use a wire that has as little resistance as possible.</em><em>Current is directly proportional to voltage, inversely proportional to resistance. One of the most common electrical measurements you'll use is the watt, a unit of electrical power: W (Watts) = E (Volts) x I (Amperes). The quantity of electric charge is measured in coulombs.</em><em>They can even pass through bones and teeth. This makes gamma rays very dangerous. They can destroy living cells, produce gene mutations, and cause cancer.</em>

Explanation:

hey mate this is the best answer if you're studying engineering!

8 0
3 years ago
Read 2 more answers
The time to failure for a gasket follows the Weibull distribution with ß = 2.0 and a characteristic life of 300 days. What is th
Aleks04 [339]

Answer:

64.11% for 200 days.

t=67.74 days for R=95%.

t=97.2 days for R=90%.

Explanation:

Given that

β=2

Characteristics life(scale parameter α)=300 days

We know that Reliability function for Weibull distribution is given as follows

R(t)=e^{-\left(\dfrac{t}{\alpha}\right)^\beta}

Given that t= 200 days

R(200)=e^{-\left(\dfrac{200}{300}\right)^2}

R(200)=0.6411

So the reliability at 200 days 64.11%.

When R=95 %

0.95=e^{-\left(\dfrac{t}{300}\right)^2}

by solving above equation t=67.74 days

When R=90 %

0.90=e^{-\left(\dfrac{t}{300}\right)^2}

by solving above equation t=97.2 days

7 0
3 years ago
Other questions:
  • The steel water pipe has an inner diameter of 12 in. and a wall thickness of 0.25 in. If the valve A is closed and the water pre
    10·1 answer
  • You work for a printing company, and you realize that your colleague sent incorrect price quotes to a client. You begin to write
    13·1 answer
  • Air is contained in a vertical piston–cylinder assembly such that the piston is in static equilibrium. The atmosphere exerts a p
    9·1 answer
  • Electrical strain gauges were applied to a notched specimen to determine the stresses in the notch. The results were εx=0.0019 a
    13·1 answer
  • In your first job with a large U.S based steel company, you have been assigned to a team tasked with developing a new low carbon
    15·2 answers
  • A small pad subjected to a shearing force is deformed at the top of the pad 0.12 in. The heigfit of the pad is 1.15 in. What is
    7·1 answer
  • Estimate the uncertainty in a 22 m/sec air velocity measurement using a Pitot tube at 20C. Assume the atmospheric pressure is 1
    7·1 answer
  • What are practical considerations you might encounter when you increase the moment of inertia (I) while keeping the cross-sectio
    13·1 answer
  • Design a program that calculates the area and circumstance of rectangle?​
    5·1 answer
  • What is the purpose of having a ventilation system on board a motorized vessel?.
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!