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
4 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]4 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
Hey y’all just wanted to say sup and don’t stress so much about the world just leave it to god and it will all work out
Vaselesa [24]

Answer:

ok

ty for the kind words

Explanation:

7 0
4 years ago
Read 2 more answers
A four-lane divided multilane highway (two lanes in each direction) in rolling terrain has five access points per mile and 11-ft
grandymaker [24]

Answer:

peak-hour volume = 1890 veh/h

Explanation:

<u>Determine the peak-hour Volume </u>

Applying the equation below

Vp =  v / ( PHF * N * Fg * Fdp )  -------------- ( 1 )

where :

Vp = 1250

v ( peak - hour volume ) =  ?

PHF ( peak hour factor ) = 0.84

N  = 2 lanes per direction

Fg ( grade adjustment for rolling terrain ) = 0.99 ≈ 1

Fdp = 0.90

<u>Back to equation 1 </u>

v = Vp (  PHF * N * Fg * Fdp )  

  = 1250 ( 0.84 * 2 * 1 * 0.90 )

  = 1890 veh/h

5 0
3 years ago
The "view factor" Fij depends on surface emissivity and surface geometry. a) True b) False
Alex

Answer:

(B) FALSE

Explanation:

view factor F_{ij} depends on the surface emissivity and the surface of geometry  view factor is the term used in radiative heat transfer. View factor is depends upon the radiation which leave the surface and strike the surface.View factor is also called shape factor configuration factor it is denoted by  F_{ij}

4 0
3 years ago
Why is a universal joint useful?
zubka84 [21]

Answer:

the are useful because they transmit a rotary motion they are used in shafts like the driveshaft in a car

Explanation:

3 0
4 years ago
A pump with a power of 5 kW (pump power, and not useful pump power) and an efficiency of 72 percent is used to pump water from a
almond37 [142]

Answer:

a) The mass flow rate of water is 14.683 kilograms per second.

b) The pressure difference across the pump is 245.175 kilopascals.

Explanation:

a) Let suppose that pump works at steady state. The mass flow rate of the water (\dot m), in kilograms per second, is determined by following formula:

\dot m = \frac{\eta \cdot \dot W}{g\cdot H} (1)

Where:

\dot W - Pump power, in watts.

\eta - Efficiency, no unit.

g - Gravitational acceleration, in meters per square second.

H - Hydrostatic column, in meters.

If we know that \eta = 0.72, \dot W = 5000\,W, g = 9.807\,\frac{m}{s^{2}} and H = 25\,m, then the mass flow rate of water is:

\dot m = 14.683\,\frac{kg}{s}

The mass flow rate of water is 14.683 kilograms per second.

b) The pressure difference across the pump (\Delta P), in pascals, is determined by this equation:

\Delta P = \rho\cdot g\cdot H (2)

Where \rho is the density of water, in kilograms per cubic meter.

If we know that \rho = 1000\,\frac{kg}{m^{3}}, g = 9.807\,\frac{m}{s^{2}} and H = 25\,m, then the pressure difference is:

\Delta P = 245175\,Pa

The pressure difference across the pump is 245.175 kilopascals.

4 0
3 years ago
Other questions:
  • Why is understanding the risks and hazards associated with fires important?
    11·2 answers
  • Which among the four that doesn't use an elbow in wiring installation a.EMT b. CPC c.PVC d.RSC<br>​
    8·1 answer
  • Quien mira WWE.<br>Respondan!​
    10·1 answer
  • PLZZ HELP ILL GIVE BRAINLYEST PLZZ HELP
    12·2 answers
  • Why are funeral home adding dining facilities to the business
    14·1 answer
  • Would anyone be able to tell me what this is? it's for a water pump​
    13·1 answer
  • Determine the output logic-levels(boolean-levels) for XNOR if the two-inputs are inverted?​
    8·1 answer
  • What is valve overlap?
    5·1 answer
  • PTAC and window-unit air conditioners often use rotary compressors, which are effective but susceptible to failure due to high h
    8·1 answer
  • Refrigerant 134a passes through a throttle valve as part of a refrigeration cycle. The fluid enters the valve as compressed liqu
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!