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
Air flows through a convergent-divergent duct with an inlet area of 5 cm² and an exit area of 3.8 cm². At the inlet section, the
Luda [366]

Answer:

The mass flow rate is 0.27 kg/s

The exit velocity is 76.1 m/s

The exit pressure is 695 KPa

Explanation:

Assuming the flow to be steady state and the behavior of air as an ideal gas.

The mass flow rate of the air is given as:

Mass Flow Rate = ρ x A1 x V1

where,

ρ = density of air

A1 = inlet area = 3.8 cm² = 3.8 x 10^-4 m²

V1 = inlet velocity = 100 m/s

For density using general gas equation:

PV = nRT

PV = (m/M)RT

PM/RT = ρ

ρ = (680000 N/m²)(0.02897 kg/mol)/(8.314 J/mol.k)(60 + 273)k

ρ = 7.11 kg/m³

Therefore,

Mass Flow Rate = (7.11 kg/m³)(3.8 x 10^-4 m²)(100 m/s)

<u>Mass Flow Rate = 0.27 kg/s = 270 g/s</u>

Now, for steady flow, the mass flow rate remains constant throughout the flow. Hence, flow rate at inlet will be equal to the flow rate at outlet:

Mass Flow Rate = ρ x A2 x V2

where,

ρ = density of air = 7.11 kg/m³ (Assuming in-compressible flow)

A2 = exit area = 5 cm² = 5 x 10^-4 m²

V2 = exit velocity = ?

Therefore:

0.27 kg/s = (7.11 kg/m³)(5 x 10^-4 m²) V2

<u>V2 = 76.1 m/s</u>

Now, for exit pressure, we use Bernoulli's equation between inlet and exit, using subscript 1 for inlet and 2 for exit:

P1 + (1/2) ρ V1² + ρ g h1 = P2 + (1/2) ρ V2² + ρ g h2

Since, both inlet and exit are at same temperature.

Therefore, h1 = h2, and those terms will cancel out.

P1 + (1/2) ρ V1² = P2 + (1/2) ρ V2²

P2 = P1 + (1/2) ρ V1² - (1/2) ρ V2²

P2 = P1 + (1/2) ρ (V1² - V2²)

P2 = 680000 Pa + (0.5)(7.11 kg/m³)[(100m/s)² - (76.1 m/s)²]

P2 = 680000 Pa + 14962.25 Pa

<u>P2 = 694962.25 Pa = 695 KPa</u>

4 0
3 years ago
If you could help it would mean alot.
scoundrel [369]

Answer:

D is the correct choice.

Explanation:

I'm assuming that this is probably a phase in the textbook or progarm you are studying, and this is just a matter of reading thoroughly.

Engineers usually benefit from catching a mistake, and would also benfit from keeping record of a misstep in order to remain clear of that mistake in the future.

Have a great day, and mark me brainliest if I am most helpful!

:)

8 0
3 years ago
Read 2 more answers
A ____________ is a term that originally was referring to a way to reproduce a technical drawing documenting an architectural or
larisa86 [58]

Answer:

The answer is  blueprint.

Explanation:

Have a nice day or night!

7 0
2 years ago
Jaden is doing an experiment to find out if plants grow taller when given plain water or sugar water. To make sure his experimen
Anettt [7]
I believe he should use two separate plants. One just for tracking the growth with plain water and the other for sugar.
3 0
3 years ago
Read 2 more answers
Describe why the motion of a follower acted on by a cam is periodic motion.
PolarNik [594]
When you go and use a periodic motion there a reason
6 0
3 years ago
Other questions:
  • To operate a vehicle in Florida, you must
    10·2 answers
  • Using Von Karman momentum integral equation, find the boundary layer thickness, the displacement thickness, the momentum thickne
    14·1 answer
  • An engine indicator is used to determine the following: (a) speed (d) m.e.p, and IHP (e) BHP (b) temperature (c) volume of cylin
    7·1 answer
  • 11.A heat engine operates between two reservoirs at 800 and 20°C. One-half of the work output of the heat engine is used to driv
    6·1 answer
  • Power is a fundamental dimension. a) True b) False
    15·1 answer
  • The alignment readings for the front of a vehicle are shown above. Camber and toe are within specification, caster is not. Techn
    10·1 answer
  • What are the two reasons for a clear cut
    10·1 answer
  • Let CFG G be the following grammar.
    7·2 answers
  • Which type of engineer is needed in the following scenario?
    8·2 answers
  • Why would the shear stress be considered as the momentum flux.
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!