Java Code-Matching Pennies
Budget: $10 – $11 USD
Running the program should first ask the user for the number of starting pennies for
each player, for example 10 or 15, and if the first player is “Even” or “Odd”. For
each round, the two players take turns: first player should be able choose “Heads” or
“Tails” using a number for each (0 or 1). After the first player’s choice, the second
player should be able to choose one of the two options as well, using a random coin flip.
You then must compare the choices and modify the number of pennies for each player
accordingly.
When one of the two players runs out of pennies, display who won each round and the
final winner (First player or second player).
Please use simple commands such as if, else if, do, while, else, switch,etc.
Information about Matching Pennies Game from wikipedia:
Matching pennies is the name for a simple game used in game theory. It is played between two players, Even and Odd. Each player has a penny and must secretly turn the penny to heads or tails. The players then reveal their choices simultaneously.. If the pennies match (both heads or both tails), then Even keeps both
pennies, so wins one from Odd (+1 for Even, -1 for Odd). If the pennies do not match
(one heads and one tails) Odd keeps both pennies, so receives one from Even (-1 for
Even, +1 for Odd).
each player, for example 10 or 15, and if the first player is “Even” or “Odd”. For
each round, the two players take turns: first player should be able choose “Heads” or
“Tails” using a number for each (0 or 1). After the first player’s choice, the second
player should be able to choose one of the two options as well, using a random coin flip.
You then must compare the choices and modify the number of pennies for each player
accordingly.
When one of the two players runs out of pennies, display who won each round and the
final winner (First player or second player).
Please use simple commands such as if, else if, do, while, else, switch,etc.
Information about Matching Pennies Game from wikipedia:
Matching pennies is the name for a simple game used in game theory. It is played between two players, Even and Odd. Each player has a penny and must secretly turn the penny to heads or tails. The players then reveal their choices simultaneously.. If the pennies match (both heads or both tails), then Even keeps both
pennies, so wins one from Odd (+1 for Even, -1 for Odd). If the pennies do not match
(one heads and one tails) Odd keeps both pennies, so receives one from Even (-1 for
Even, +1 for Odd).
Related categories:
Business, Accounting, Human Resources & Legal
Software Development
Coding
Eclipse
Computer Science