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
Refectories are one of the types of ceramics that have low melting temperature. a)-True b)-False
MaRussiya [10]

Answer:

b). False

Explanation:

A refractory material is a type of material that can withstand high temperatures without loosing its strength. They are used in reactors, furnaces, kilns, etc.

    Refractory materials are certain super alloys and ceramics materials.

Properties of refractory materials :

1. Refractory materials have high melting point.

2.They acts barriers between high heat zone and low heat zone.

3. The specific heat of refractory material is very low.

4. Refractories that have high bulk densities are better in quality.

Hence, Refractory materials have a very high melting temperature.

3 0
3 years ago
You may wonder who the rest goes
Deffense [45]

Answer:

no not really

Explanation:

From your friendly neighborhood cereal killer,

Sir. BLOODPR1NCE

6 0
2 years ago
The specific volume of mercury is .00007 m^3/Kg. What is its density in lbm/ft^3?
aalyn [17]

Answer:

891.027 lbm/ft³

Explanation:

See it in the pic

5 0
3 years ago
____ grinders are used to grind diameters, shoulders, and faces much like the lathe is used for turning, facing, and boring oper
skelet666 [1.2K]

Answer:

Cylindrical

Explanation:

<em>A cylindrical grinder </em><em>is a tool for shaping the exterior of an item. Although cylindrical grinders may produce a wide range of forms, the item must have a central axis of rotation. Shapes such as cylinders, ellipses, cams, and crankshafts are examples of this.</em><em> Cylindrical grinding</em><em> machines are specialized grinding machines that are used to process cylinders, rods, and similar workpieces. The cylinders revolve in one direction between two centers, while the grinding wheel or wheels are close together and rotate in the other direction.</em>

8 0
2 years ago
Calculate the load, PP, that would cause AA to be displaced 0.01 inches to the right. The wires ABAB and ACAC are A36 steel and
Nataly [62]

Answer:

P = 4.745 kips

Explanation:

Given

ΔL = 0.01 in

E = 29000 KSI

D = 1/2 in  

LAB = LAC = L = 12 in

We get the area as follows

A = π*D²/4 = π*(1/2 in)²/4 = (π/16) in²

Then we use the formula

ΔL = P*L/(A*E)

For AB:

ΔL(AB) = PAB*L/(A*E) = PAB*12 in/((π/16) in²*29*10⁶ PSI)

⇒  ΔL(AB) = (2.107*10⁻⁶ in/lbf)*PAB

For AC:

ΔL(AC) = PAC*L/(A*E) = PAC*12 in/((π/16) in²*29*10⁶ PSI)

⇒  ΔL(AC) = (2.107*10⁻⁶ in/lbf)*PAC

Now, we use the condition

ΔL = ΔL(AB)ₓ + ΔL(AC)ₓ = ΔL(AB)*Cos 30° + ΔL(AC)*Cos 30° = 0.01 in

⇒  ΔL = (2.107*10⁻⁶ in/lbf)*PAB*Cos 30°+(2.107*10⁻⁶ in/lbf)*PAC*Cos 30°= 0.01 in

Knowing that   PAB*Cos 30°+PAC*Cos 30° = P

we have

(2.107*10⁻⁶ in/lbf)*P = 0.01 in

⇒  P = 4745.11 lb = 4.745 kips

The pic shown can help to understand the question.

5 0
3 years ago
Other questions:
  • 1. Why is outside air mixed with return air?​
    6·1 answer
  • A piston cylinder assembly fitted with a slowly rotating paddle wheel contains 0.13 kg of air at 300K. The air undergoes a const
    10·1 answer
  • What is the Principle of Entropy Increase?
    9·1 answer
  • There are 30 students in a class. Choose the statement that best explains why at least two students have last names that begin w
    12·1 answer
  • Design a digital integrator using the impulse invariance method. Find and give a rough sketch of the amplitude response, and com
    15·1 answer
  • A pool of contaminated water is lined with a 40 cm thick containment barrier. The contaminant in the pit has a concentration of
    11·1 answer
  • Digital leaders are people who __ others down a particular path.
    13·2 answers
  • What kinds of problems or projects would a mechanical engineer work on?
    11·1 answer
  • What is the name of the type of rocker arm stud that does not require a valve adjustment?
    12·1 answer
  • To understand the concept of moment of a force and how to calculate it using a scalar formulation.
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!