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
8. Two 40 ft long wires made of differing materials are supported from the ceiling of a testing laboratory. Wire (1) is made of
san4es73 [151]

Answer:

Material K has a modulus of elasticity E=3.389× 10¹¹ Pa

Material H has a modulus of elasticity E=1.009 × 10⁹ Pa

Material K has higher value of modulus of elasticity than material H

Material K is stiffer.

Explanation:

Wire 1 material H

Length=L = 40 ft =12.192 m

Diameter= 3/8 in = 0.009525 m

Area= A= πr²,where r=0.009525/2 =0.004763

A=3.142*0.004763² =0.00007126 m²

Force, F= 225 lb=  225*4.45 =1001.25 N

Change in length =Δ L= 0.10 in = 0.00254

To find modulus of elasticity apply'

E=F*L/A*ΔL

E=1001.25*12.192/(0.004763*0.00254)

E= 1009027923.58 Pa

E=1.009 × 10⁹ Pa

For Wire 2 material K

Length=L= 40 ft =12.192 m

Diameter = 3/16 in = 0.1875 in = 0.004763 m

Area= πr² = 3.142 * (0.004763/2)² = 0.00000567154 m²

Force, F= 225 lb=  225*4.45 =1001.25 N

Change in length =Δ L= 0.25 in =0.00635 m

To find modulus of elasticity apply'

E=F*L/A*ΔL

E= (1001.25*12.192)/(0.00000567154 * 0.00635 )

E=338955422575 Pa

E=3.389× 10¹¹ Pa

Material  K has a greater modulus of elasticity

The material with higher value of E is stiffer than that with low value of E.The stiffer material is K.

8 0
3 years ago
How much does 5 acres of land cost in the US?
Dvinal [7]

Answer:

Larson, an economist, who placed the total value of $23 trillion for the entire 1.9 billion acres of land in the United States. This means that the average cost for an acre of land is $12,000 or $60,000 for 5 acres of land. Almost half of the land in the US is used for agricultural purposes.

Explanation:

6 0
4 years ago
Steam enters a steady-flow adiabatic nozzle with a low inlet velocity (assume ~0 m/s) as a saturated vapor at 6 MPa and expands
Sergio [31]
Yea bro I don’t really know
7 0
3 years ago
Who was part of dempwolf his firm when he first started
Zinaida [17]

Explanation:

Dempwolf created by John Augustus, Among the most prominent innovative solutions in Southern California Pennsylvania was established by Dempwolf with  brother Reinhardt or uncle's son Frederick entered the company of J.A. Dozens of structures in 10 states were engineered by Dempwolf.

5 0
3 years ago
Anyone help me please ?
Degger [83]

Answer:

I can help but I need to know what it looking for

5 0
3 years ago
Other questions:
  • A circuit-switching scenario in whichNcs users, each requiring a bandwidth of 25 Mbps, must share a link of capacity 150 Mbps.
    12·1 answer
  • Determine the required dimensions of a column with a square cross section to carry an axial compressive load of 6500 lb if its l
    12·2 answers
  • You just purchased a 400-L rigid tank for a client who works in the gas industry. The tank is delivered pre-filled with 3 kg of
    8·1 answer
  • Amplifiers are extensively used in the baseband portion of a radio receiver system to condition the baseband signal to produce a
    5·1 answer
  • Consider a Carnot refrigeration cycle executed in a closed system in the saturated liquid-vapor mixture region using 0.96 kg of
    11·1 answer
  • A Barnes and Books is interested in purchasing a two-story building for a new
    5·1 answer
  • (Signal Property) Under what condition is a discrete-time signal x[????] or a continuous-time signal x(????) periodic? Determine
    5·1 answer
  • A continuous random variable, X, whose probability density function is given by f(x) = ( λe−λx , if x ≥ 0 0, otherwise is said t
    12·1 answer
  • What process is used to remove collodal and dissolved organic matter in waste water ​
    10·1 answer
  • 'Energy' has the potential to:
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!