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
Imagine you are making a pizza, you start of with the dough for the crust in a large ball. You then begin to roll out the pizza
DochEvi [55]

Answer: The force exerted on the dough.

Explanation:

The force is responsible for stimulating the stress.

Recall that:

stress= Tensile force/area.

5 0
2 years ago
What is relation of crankshaft and camshaft
Monica [59]
Mierda me dices solo necesito puntos
6 0
2 years ago
Read 2 more answers
Timescale limits knowledge for scientists because it is difficult for them to see much beyond their lifetimes. Question 1 option
vaieri [72.5K]

Answer:

I think true

Explanation:

Well I mean...we cant see the future. Certain things will be achieveable in different ganerations like going on mars

8 0
2 years ago
The common type of defects found when soldering on a printed circuit board
sammy [17]

Explanation:

Solder Bridges

Plating Voids

Non-wetting or dewetting.

5 0
3 years ago
An engineering drawing shows the: (A) dimensions, tolerances, cost, and sales or use volume of a component.(B) dimensions, toler
Leto [7]

Answer:

(B) dimensions, tolerances, materials, and finishes of a component.

Explanation:

An engineering drawing :

  An  engineering drawing is a technical drawing which draws the actual component .

An engineering drawing shows

1. Materials

2.Dimensions

3.Tolerance

4.Finishes of a component

Engineering drawing does not shows any information about the cost of component.

So the option B is correct.

3 0
3 years ago
Other questions:
  • ): drivers must slow down from 60 to 40 mi/hr to negotiate a severe curve. A warning sign is visible for a distance of 120 ft. H
    7·1 answer
  • When replacing a timing belt, many experts and vehicle manufacturers recommend that all of the following should be replaced exce
    13·1 answer
  • In many problems where the potential energy is considered between two objects, the potential energy is defined as zero when the
    8·1 answer
  • A spacecraft is fueled using hydrazine ​(N2H4​; molecular weight of 32 grams per mole​ [g/mol]) and carries 1 comma 630 kilogram
    12·1 answer
  • PLEASE HELP!!! ILL GIVE BRANLIEST *EXTRA POINTS* dont skip :((
    14·2 answers
  • 5. The pin support at A allows _______. Select the one that applies. (a) displacement in the x direction (b) rotation about its
    15·1 answer
  • Is a unit of measurement for angles
    15·1 answer
  • ______ are an idication that your vehicle may be developing a cooling system problem.
    14·1 answer
  • In the last 5 meters of braking, you lose ___ of your speed.
    6·1 answer
  • Engineers please help im not good when it comes to drawing​
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!