6.4 Bowling program
Write a program that reads a data file and
uses an array to figures out the bowling scores.
In bowling, 10 pins are set up for each frame and
the player gets two chances to knock them down.
If the player knocks down less than 10 ten pins
down with the two balls his/her score for that frame
is the total number of pins knocked down.
If the player knocks down all of the pins with two balls, (a spare,
marked with a "/") the player gets 10 points plus the
number of pins knocked down with the next ball.
If the player knocks down all of teh pins with one ball, (a strike,
marked with an "X") the player gets 10 points plus the
number of pins knocked down with the next two balls.
At the beginning of your program printout the following:
- Your name
- CIS265 Louis Taber
- Lab: 6.2: Bowling.
Your input data will be:
- Players name
- Number of pins knocked down with a ball.
- -1 For end of game (next record new players name)
- -2 For end of data file
For each game print out all ten frames. For each frame print out
the following:
- the number of pins knocked down for each ball.
- If the frame was a strike or a spare.
- The running score for the player.
For example: (Print error messages when you find the error.)
Name: John Doe
Frame 1: Ball 1: 10 Ball 2: none Strike Score: 20
Frame 2: Ball 1: 5 Ball 2: 5 Spare Score: 36
Frame 3: Ball 1: 6 Ball 2: 0 Score: 42
Frame 4: Ball 1: 10 Ball 2: none Strike Score: 54
Frame 5: Ball 1: 0 Ball 2: 2 Score: 56
Frame 6: Ball 1: 0 Ball 2: 1 Score: 57
Frame 7: Ball 1: 4 Ball 2: 5 Score: 66
Frame 8: Ball 1: 4 Ball 2: 6 Spare Score: 83
Frame 9: Ball 1: 7 Ball 2: 3 Spare Score: 103
Frame 10: Ball 1: 10 Ball 2: none Strike Score: 133
Extra Ball 1: 10 Extra Ball 2: 10
You will also need to print out your results using
the "traditional" format for a bowling score sheet.
Name: John Doe
( Error message will go here -- if there are any )
___1___2___3___4___5___6___7___8___9__10___
| |X|5|/|6|0| |X|0|2|0|1|4|5|4|/|7|/|X|X|X|
| 20| 36| 42| 54| 56| 57| 66| 83|103| 133|
-------------------------------------------
Remember that after the last frame, up to two additional balls
may be played. (Two for a strike and one for a spare.)
Your program also needs to check for errors in the input data:
The types of errors your program needs to look for are:
- More than 10 pins per frame.
(In your error message printout the number of the errant frame,
and count the frame as a total of zero pins.)
- More than 10 pins per ball.
(In your error message printout the number of the errant frame,
and count the frame as a total of zero pins.)
- Too many balls total. (Print error message, but score game using
the balls needed.)
- Too few balls. (Use zero for all missing balls.)
Run your program with the test data available at:
Test your program with the following sample data sets.
The first one has (hopefully) no errors. It is available by anonymous ftp at
ftp://lt.tucson.az.us/pub/c/bowling.dat.
The second one has lots of errors, to check your error handling code.
It is available by anonymous ftp at
ftp://lt.tucson.az.us/pub/c/bwerror.dat.
Mark your output two printouts and your listing with:
- Your name
- TABER CIS265
- Lab 6.4: Bowling
- The compiler and OS that you used.
Please turn your lab in to Pima Community College employee
in room A-115 ofthe Santa Rita Building.
Ask them to place it in the lab folder in
Louis Taber's mailbox.
Instructor: ltaber@pima.edu ** My new Home at GeoApps in Tucson ** The Pima College Site