## During his turn, a player rolls five dice and adds up his points based on the following rules.

### engineering

##### Description

Write a MATLAB program that allows two players to play the following dice game.

The objective of the game is to be the first player to reach a score of 5000 points.

The two players take alternating turns.

During his turn, a player rolls five dice and adds up his points based on the following rules.

·       Each 1 dice = 100 points

·       Each 5 dice = 50 points

·       Three of a kind count as follows:

o   Three 1’s = 1000 points

o   Three 2’s = 200 points

o   Three 3’s = 300 points

o   Three 4’s = 400 points

o   Three 5’s = 500 points

o   Three 6’s = 600 points

If the player rolls no counters or a “garbage” roll his turn is over and the second player takes a turn.

If the player scores on his first role he can choose to roll again of he can stop and take the points for that turn.  He can continue rolling until he rolls a garbage roll or decides to stop. But, if the player rolls again and gets a garbage roll then he loses all of his points for that turn (gets a score of 0 for that turn) and the next player takes his turn.

The MATLAB program should show each roll of the 5 dice, automatically count the score of the roll and then ask the player if he wants to roll again or stop and take his points.  If the player rolls a garbage roll then the program would set the players score for that turn to zero. Player 2 would then take his turn.  The program should keep the total score for each player and declare the first player to reach 5000 points the winner.

You can use the randi command to randomly select a number between 1 and 6 to simulate rolling a single dice.  Use loops and if-else-if-else statement to calculate the score.

Use input statements to ask the player if he wants to roll again or stop