The main program for this chapter is a simplified dice game. In this game, you are given $100 dollars of virtual money. On each turn, you bet two dollars. The computer will roll five dice. You can elect to keep each die or roll it again. On the second roll, the computer checks for various combinations. You can earn money back for rolling pairs, triples, four and five of a kind, and straights (five numbers in a row) Figures 4.1 and 4.2 illustrate the game in action.
The basic concepts of this game are much like the ones you used in the earlier programs. Keeping track of all five dice can get very complicated, so this program uses arrays and loops to manage all the information.