The George Washington University
School of Engineering and Applied Science
Department of Electrical Engineering and Computer Science
CSci 131 -- Algorithms and Data Structures I -- Spring 2001
Project #1
Due Date: Monday, February 5, 2001
In this project you will develop a program to keep score for a game of ten-pin bowling. In case you are not familiar with this popular indoor sport, here are the rules.
![]() |
![]() |
A game consists of ten frames: In each frame, a player rolls the ball twice and receives a number of points equal to the total pins knocked down by the two balls. After a player rolls both balls, the pins are set up again and the next player gets a turn.
When all players (usually up to four players) have taken their turns, the frame is over and a new frame begins. Each player’s score is kept as a running total for all frames since the start of the game. In this oversimplified view, a player knocking down all pins in all frames would get a total of 100 points.
Bowling is actually a bit more interesting, because of bonus points which result in a maximum score of 300 points. A player who knocks down all ten pins with both balls in a frame (say, 4 with the first ball and the remaining 6 with the second ball), is said to have bowled a spare. In this case, the player’s score from the first ball of the next frame is added to the 10 from the current frame. That is, a player bowling a spare in frame 5, say, and hitting 4 pins with the first frame 6 ball, gets a total of 14 points for frame 5. Naturally the 4 still counts in frame 6 as well.
A player who knocks down all ten pins with the first ball of a frame is said to have bowled a strike. There is no second ball rolled, and the player gets a bonus of the next two balls rolled. For example, a player bowling a strike in frame 5 and 9 in frame 6 receives a total of 19 points for frame 5 and 9 points for frame 6.
Suppose a player bowls two strikes in a row, say in frames 5 and 6, and then hits 3 and 6 with the two balls of frame 7. This player receives, for frame 5, a total of 10+10+3=23, for frame 6 a total of 10+3+6=19, and for frame 7, a total of 3+6=9.
One final rule applies to frame 10. If a player bowls a spare in that frame, the pins are set back up and the player gets one more ball,earning a bonus of the pins hit with that ball. If the player bowls a strike in frame 10, the pins are set back up and she gets two additional balls. It follows that a player bowling strikes on all three balls in the last frame receives a total of 30 points for that frame.
Every bowler's dream is to bowl a perfect game, that is, a strike on every roll. It is easy to calculate that the maximum possible score in a game is 300.
Number of players >3
PLAYER| 1| 2|
3| 4| 5|
6| 7| 8|
9| 10|
-----------------------------------------------------------------------------
1 | 3 0|
| 3|
-----------------------------------------------------------------------------
2 | 4 5|
| 9|
-----------------------------------------------------------------------------
3 | 4 4|
| 8|
-----------------------------------------------------------------------------
At the end of the game, the result might be
PLAYER| 1| 2|
3| 4| 5|
6| 7| 8|
9| 10|
-----------------------------------------------------------------------------
1 | 3 0| X |
6 0| 4 5| 7 0| X |
X | 4 4| 8 1| 7 1|
| 3|
19| 25| 34| 41|
65| 83| 91| 100|
108|
-----------------------------------------------------------------------------
2 | 4 5| X |
9 /| 9 0| 5 0| X |
9 /| 8 0| 9 0| 9 / 8|
| 9|
29| 48| 57| 62|
82| 100| 108| 117| 135|
-----------------------------------------------------------------------------
3 | 4 4| 9 /|
7 1| 7 2| 1 7| 4 4| 6
2| 8 0| 8 0| X X X|
| 8|
25| 33| 42| 50|
58| 66| 74| 82|
112|
-----------------------------------------------------------------------------
I will give you a file of test data corresponding to the above 3-person game. This file is called info/bowling.dat. Your program will, each time a ball must be rolled, read a value from the file. Because you have the attached box score, you can check the scoring to ascertain that your program is working correctly.
In the box score, the top two boxes of each frame show the number of pins struck; the lower box shows the running total for that player. A strike is indicated by an X in the first upper box, and a spare is indicated by a slash or filled-in triangle in the second upper box. Your program should display numbers in about the same format as the box score (without the boxes), so that a bowling fan would recognize the scoring format.