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
A 225 MPa conducted in which the mean stress was 50 MPa and the stress amplitude was (a) Compute the maximum and (b) Compute the
tamaranim1 [39]

Answer:

Explanation:

Given data in question

mean stress  = 50 MPa

amplitude stress  = 225 MPa

to find out

maximum stress, stress ratio, magnitude of the stress range.

solution

we will find first  maximum stress  and minimum stress

and stress will be sum of (maximum +minimum stress) / 2

so for stress 50 MPa and 225 MPa

\sigma _{m} =  \sigma _{maximum} + \sigma _{minimum}  / 2

50 =  \sigma _{maximum} + \sigma _{minimum}  / 2    ...........1

and

225 =  \sigma _{maximum} + \sigma _{minimum}  / 2      ...........2

from eqution 1 and 2 we get maximum and minimum stress

\sigma _{maximum} = 275 MPa        ............3

and \sigma _{minimum} = -175 MPa     ............4

In 2nd part we stress ratio is will compute by ratio of equation 3 and 4

we get ratio =  \sigma _{minimum} / \sigma _{maximum}

ratio = -175 / 227

ratio = -0.64

now in 3rd part magnitude will calculate by subtracting maximum stress - minimum stress i.e.

magnitude = \sigma _{maximum} - \sigma _{minimum}  

magnitude = 275 - (-175) = 450 MPa

3 0
3 years ago
Can i join three 12 volts batteriesto give me 24 volts output​
bulgar [2K]

Answer:

YES

Explanation:

If we connect batteries in series then the output voltage is the sum of the individual voltage of each battery i.e if you connect three 12 volts batteries in series then their output voltage will be 12+12+12=36 volts, but the current rating of the batteries in series will be same of the individual battery rating in 'mah'.

But when we connect the batteries in parallel their voltage is not added  but their current rating in mah is addition of their individual rating.

So, If you want 24 volts from three 12 volts battery then you can connect two of them in series and the other one in parallel with them this will give 24 volts and the current will be addition of the two series batteries and the third which is in parallel with them. You can use this configuration if current value is not a big factor.

8 0
3 years ago
The level of water in a dam is 6 m. The rectangular gate ABC is pinned at point B so it can rotate freely about this point. When
olchik [2.2K]

Answer:

The reaction at support B

Rb= 235440N

The reaction at support C

RC= 29430N

Explanation : check attachment

6 0
3 years ago
A number 12 copper wire has a diameter of 2.053 mm. Calculate the resistance of a 37.0 m long piece of such wire.
Alinara [238K]

Answer:

R=1923Ω

Explanation:

Resistivity(R) of copper wire at 20 degrees Celsius is 1.72x10^-8Ωm.

Coil length(L) of the wire=37.0m

Cross-sectional area of the conductor or wire (A) = πr^2

A= π * (2.053/1000)/2=3.31*10^-6

To calculate for the resistance (R):

R=ρ*L/A

R=(1.72*10^8)*(37.0)/(3.31*10^-6)

R=1922.65Ω

Approximately, R=1923Ω

5 0
3 years ago
11. When selecting a route for a long trip, you should
mamaluj [8]

Answer:

b

Explanation:

i think do kill me if im wrong

6 0
3 years ago
Read 2 more answers
Other questions:
  • Which is the correct order for handwashing
    11·2 answers
  • If a barrel of oil weighs 1.5 kN, calculate the specific weight, density, and specific gravity of the oil. The barrel weighs 110
    7·1 answer
  • A 230 V shunt motor has a nominal armature current of 60 A. If the armature resistance is 0.15 ohm, calculate the following: a.
    5·1 answer
  • How do we need to prepare for the future?
    10·1 answer
  • Test if a number grade is an A (greater than or equal to 90). If so, print "Great!". Hint: Grades may be decimals. Sample Run En
    15·1 answer
  • An astronomer of 65 kg of mass hikes from the beach to the observatory atop the mountain in Mauna Kea, Hawaii (altitude of 4205
    15·1 answer
  • A school is playing $0.XY per kWh for electric power. To reduce its power bill, the school installs a wind turbine with a rated
    6·1 answer
  • PLEASE HELPPPPPPP!!!!,
    10·2 answers
  • What is the purpose of encryption?
    13·1 answer
  • Discuss importance of good communication system​
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!