C++ code A simple version of snakes and ladder Implement a game that initially asks how many players will play the game. The game will then ask the  name of each player. The game is played as follows: 1. The game is played iteratively. In every iteration, every player takes turn to roll a dice. The face  value of dice is added to the total score of the player. 2. The first player to reach 100 score gets 1st position. The second player to reach 100 score gets  2 nd position. 3. When a player reaches 100, he no longer remains part of the play. If current score + face value is  greater than 100, then the player will retry in the next iteration, i.e., the score must exactly  become 100. 4. There are ladders at 20 and 60. If a player’s score becomes exactly 20, the score becomes 40. If  a player’s score is exactly 60, the score becomes 75. Similarly, there are snakes at 50 and 90. If a  player’s score is exactly 50, the score become 40. If a player’s score is exactly 90, the score  becomes 79. 5. When n-1 players have reached 100, the game ends and the position of all players that  participated in the game is displayed in ascending order.  6. During game play, some useful messages should be displayed, so that one can know what is  going on in the game, such as: Please enter the number of players: 2 Please enter the name of Player 1: ABC Please enter the name of Player 2: XYZ It is ABC’s turn, please enter any key to continue. ABC got 5. The total score of ABC is now 5. It is XYZ’s turn, please enter any key to continue. XYZ got 6. The total score of XYZ is now 6. It is ABC’s turn, please enter any key to continue. ABC got 3. The total score of ABC is now 8. . . . It is XYZ’s turn, please enter any key to continue. XYZ got 4. The total score of XYZ is 50. There is a snake at 50, so total score is now 40. Use queue for this problem. You can use the queue class available in STL. You can only use push,  pop, front, and empty functions of STL queue. Apart from queues, you cannot use any other data  structures including arrays in any way (not even for storing the record of players that have already  finished the game).

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter5: Control Structures Ii (repetition)
Section: Chapter Questions
Problem 20PE: When you borrow money to buy a house, a car, or for some other purpose, you repay the loan by making...
icon
Related questions
Question

C++ code

A simple version of snakes and ladder
Implement a game that initially asks how many players will play the game. The game will then ask the 
name of each player. The game is played as follows:
1. The game is played iteratively. In every iteration, every player takes turn to roll a dice. The face 
value of dice is added to the total score of the player.
2. The first player to reach 100 score gets 1st position. The second player to reach 100 score gets 
2
nd position.
3. When a player reaches 100, he no longer remains part of the play. If current score + face value is 
greater than 100, then the player will retry in the next iteration, i.e., the score must exactly 
become 100.
4. There are ladders at 20 and 60. If a player’s score becomes exactly 20, the score becomes 40. If 
a player’s score is exactly 60, the score becomes 75. Similarly, there are snakes at 50 and 90. If a 
player’s score is exactly 50, the score become 40. If a player’s score is exactly 90, the score 
becomes 79.
5. When n-1 players have reached 100, the game ends and the position of all players that 
participated in the game is displayed in ascending order. 
6. During game play, some useful messages should be displayed, so that one can know what is 
going on in the game, such as:
Please enter the number of players: 2
Please enter the name of Player 1: ABC
Please enter the name of Player 2: XYZ
It is ABC’s turn, please enter any key to continue.
ABC got 5. The total score of ABC is now 5.
It is XYZ’s turn, please enter any key to continue.
XYZ got 6. The total score of XYZ is now 6.
It is ABC’s turn, please enter any key to continue.
ABC got 3. The total score of ABC is now 8.
.
.
.
It is XYZ’s turn, please enter any key to continue.
XYZ got 4. The total score of XYZ is 50. There is a snake at 50, so total score is now 40.
Use queue for this problem. You can use the queue class available in STL. You can only use push, 
pop, front, and empty functions of STL queue. Apart from queues, you cannot use any other data 
structures including arrays in any way (not even for storing the record of players that have already 
finished the game).

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Mathematical functions
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr