Starting from:

$25

CS143-Assignment 2 First to One Simulation Solved

This programming exercise is based on Programming Challenge 11 from the Gaddis text. You are to write the simulation for a game played by two or more players. In the game, each player starts out with some number of points. Each player takes a turn rolling a dice. The amount generated by the dice is subtracted from the player’s points. The first player with exactly one point remaining wins. If a player’s remaining points minus the amount generated by the dice results in a value less than one, then the amount is added to the player’s points.

At the start of the game, prompt the user for these values:

·        the number of points to start with

·        the number of players

Once these values are provided by the user, the simulation runs to completion, playing itself until one of the players wins (i.e., gets a score of one). This is a simulation. It is not supposed to be a game played interactively by the user.

As the simulation proceeds, output lines of text showing the status after each player’s turn, indicating:

·        what player is playing (e.g., player 0, player 1, etc.)

·        what value was generated by rolling the dice

·        points remaining for that player

·        when one of the players wins, announce the winner

More products