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
You work in a furniture store. You receive a
spin [16.1K]

Answer:

18 pieces of furniture

Explanation:

Since you receive $120.93 per furniture piece and a the month's commission is $2,176.74 you divide the commission by the furniture price.

  • 2176.74/120.93
3 0
3 years ago
Read 2 more answers
The correct area in sq. Inches and sq. Feet is: Select one: a. 966.76 sq. Inches and 8.056 sq. Feet b. 96.676 sq. Inches and 8.0
kogti [31]

Answer:

c. 96.676 sq. Inches and 0.671 sq. Feet

Explanation:

From the list of the given option, we are told to chose the correct area in sq. inches that correspond to sq. Feet.

If we recall from the knowledge of our conversion  table that,

1 sq feet = 144 sq inches

Then, let's confirm if the option were true.

a.  966.76 sq. Inches and 8.056 sq. Feet

Assuming

if 1 sq feet = 8.056

in sq inches, we have ( 8.056 × 144 ) sq inches

= 1160.064 sq. inches

So, 1160.064 sq. inches is equal to 8.056 sq. Feet. Then option 1 is wrong

b. 96.676 sq. Inches and 8.056 sq. Feet

if 1 sq feet = 8.056

in sq inches, we have ( 8.056 × 144 ) sq inches

= 1160.064 sq. inches

So, 1160.064 sq. inches is equal to 8.056 sq. Feet. Then option 2 is wrong/

c. 96.676 sq. Inches and 0.671 sq. Feet

if 1 sq feet = 0.671

in sq inches, we have ( 0.671 × 144 ) sq inches

=  96.624 sq. Inches which is closely equal to 96.676 sq. Inches

Therefore, this is the correct answer as it proves that 96.676 sq. Inches = 0.671 sq. Feet

8 0
3 years ago
Without motorcycle riders are at risk of severe injury in a crash ?
nekit [7.7K]

Answer:

The correct option is;

A. proper protection

Explanation:

Motorcycle riders ride the motorcycle while at some level of speed while  having the entire body exposed to be a major part of any collision.

Injuries sustained from motorcycle accidents are several times more severe than injuries sustained by occupants of a car that is fully protected by the metallic panel in the same and even more serious accident scenarios

Hence, motorcycle riders require adequate protection by putting on available motorcyclist safety gear

Therefore, to reduce the risk of severe injury n a crash, motorcycle riders require proper protection.

5 0
3 years ago
Read 2 more answers
- WHEN YOU ARE TOWING A TRAILER:
zheka24 [161]

Answer:

And Im still going with B..

7 0
2 years ago
What tool is used to measure aggregates in laying tools<br>​
denpristay [2]

Answer:

Sieve Shaker

Explanation:

6 0
2 years ago
Other questions:
  • The button on the _ valve should be held when pressure bleeding the brakes
    8·1 answer
  • Write a C program that will update a bank balance. A user cannot withdraw an amount ofmoney that is more than the current balanc
    13·1 answer
  • A thick aluminum block initially at 26.5°C is subjected to constant heat flux of 4000 W/m2 by an electric resistance heater whos
    10·1 answer
  • Technician A says that squeeze-type resistance spot welding (STRSW) may be used on open butt joints. Technician B says that repl
    14·1 answer
  • Select four types of engineers who might be involved in the development of a product such as an iPhone.
    7·2 answers
  • Where do greywater pipes generally feed into?
    14·1 answer
  • Your friend has two substances A and B which are compressed liquid and superheated vapor respectively. Both are in rigid vessels
    15·1 answer
  • Estimate the luminosity of a 3 -solar-mass main-sequence star; of a 9 -solar-mass main-sequence star. Can you easily estimate th
    5·1 answer
  • A TV USE 75 WATTS WHILE IN USED ASSMING THAT ITIS USED 4 HOURS EVERY DAY HOW MUCH ENERGY IN 4 IN KWH WOULD THE TV CONSUME ANNUAL
    13·2 answers
  • During welding in the vertical position, the torch angle can be varied to control sagging.
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!