UMBC CS 201,Spring 05
UMBC CMSC 201 Spring '05 CSEE | 201 | 201 S'05 | lectures | news | resources |discussion| help

CMSC 201
Programming Project Two
Bowling Scores

Out: Tuesday 3/8/05
Due: Before Midnight, Monday 3/28/05

The design document for this project, design2.txt ,
is due: Before Midnight, Tuesday 3/15/05

The Objective

The objective of this assignment is to give you practice with arrays, passing arrays to functions, designing a project, designing functions and using separate compilation.

The Background

In 10-pin bowling, a player will bowl 10 frames to complete a game. At the beginning of each frame the player is given 10 pins to attempt to knock down. S/he may roll two balls in order to accomplish this goal. If the player knocks down all 10 pins with the first ball, this is known as a strike, and no more balls are rolled in that frame. If the player knocks down all 10 pins, using both rolls, it is known as a spare. If there are pins still standing after both balls have been rolled, the score for that frame is the number of pins the player knocked down.
    The scoring is handled differently when a strike or spare is rolled, so that bonus points can be earned.

    If the player gets a strike, the score for that frame is 10 plus the total number of pins knocked down in the next two throws. In the case of a strike, there is no second roll in that frame. A strike is indicated on the score sheet with an X.

    If the player gets a spare, the score for that frame is 10 plus the total number of pins knocked down with the next throw. A spare is indicated on a score sheet with a /.

    If the total number of pins knocked down in the two throws is less than ten, then that total number is the score for the frame.

    If a strike is scored in the tenth frame, two more balls are thrown to determine the score for that frame. A spare in the tenth frame allows the player to roll one more ball to complete the scoring of the tenth frame.

Here is a sample score sheet :

Frame -1- -2- -3- -4- -5- -6- -7- -8- -9- -10- Extra
Ball 1 8 6 X X 3 9 X 6 X 7 9
Ball 2 1 / . . 5 / . / . / .
Score 9 29 52 70 78 98 118 138 158 177 .

Explanation of scores:

The score shown at the bottom is cumulative. For instance the score for frame 2 is 10 (for the spare) plus the 10 on the next ball. That is added to the frame 1 score of 9 to yield a total score of 29 through the second frame. Similarly, the score for the third frame is 10 (for the strike) plus the 10 on the next ball, plus the 3 on the next ball, for a total of 23. That added to the previous score of 29 yields a total of 52 through the third frame.

Here is a Bowling Score Calculator that I found on the web. I tried it out briefly and saw correct answers, however, I can't claim that it will always be correct. The sample runs of my program, shown below are correct.

The Task

Your assignment is to write a program that simulates the scoring of one player's bowling game. Your program should prompt the user for scores for each ball of each frame and stop prompting for scores at the end of the game. After the game is over, your program must produce a score sheet for the game.

Assumptions

  • You may assume that all input will be integers.

  • You MAY NOT assume that the integers are valid integers for a bowling score. Your program must be robust, so it should reject input that isn't within the range of possible scores for a single roll and reprompt for a valid score. Also your program should stop asking for input at the appropriate time, indicate that the game is over, and produce the score sheet.

Hints

  • Although it is obvious that all input should be between 0 and 10, input of 6 on the first ball and 8 on the second ball is also invalid, since there were only 10 pins, not 14.
  • It is expected that you will use three one-dimensional arrays to implement this project, one for the scores on the first ball, one for the scores on the second ball, and one for the cumulative score. If you would prefer to use a single two-dimensional array instead, that's fine.

Requirements

  • You must use separate compilation for this project.
  • You must use arrays and have at least one function that takes an array (or arrays) as an argument(s). A good design would require more than one function that takes array(s) as arguments.
  • You must use top-down design.
  • Your header file must act as a user interface, meaning each function prototype must have a full function header comment above it. Function header comments are also required above the function definitions themselves.

Sample Run

[102] a.out This is where the greeting goes Write your own version that explains the game of bowling, what this program does, and what is expected of the user Enter # of pins knocked down with the 1st ball of frame 1 : 8 the 2nd ball of frame 1 : 1 Enter # of pins knocked down with the 1st ball of frame 2 : 6 the 2nd ball of frame 2 : 4 You got a SPARE !! Enter # of pins knocked down with the 1st ball of frame 3 : 10 Congratulations, you got a STRIKE !!! Enter # of pins knocked down with the 1st ball of frame 4 : 10 Congratulations, you got a STRIKE !!! Enter # of pins knocked down with the 1st ball of frame 5 : 3 the 2nd ball of frame 5 : 5 Enter # of pins knocked down with the 1st ball of frame 6 : 9 the 2nd ball of frame 6 : 2 Number of pins must be between 0 and 1, inclusive Enter # of pins knocked down with the 2nd ball : 1 You got a SPARE !! Enter # of pins knocked down with the 1st ball of frame 7 : 15 Number of pins must be between 0 and 10, inclusive Enter # of pins knocked down with the 1st ball : -5 Number of pins must be between 0 and 10, inclusive Enter # of pins knocked down with the 1st ball : 10 Congratulations, you got a STRIKE !!! Enter # of pins knocked down with the 1st ball of frame 8 : 6 the 2nd ball of frame 8 : 4 You got a SPARE !! Enter # of pins knocked down with the 1st ball of frame 9 : 10 Congratulations, you got a STRIKE !!! Enter # of pins knocked down with the 1st ball of frame 10 : 7 the 2nd ball of frame 10 : 3 You got a SPARE !! Enter # of pins knocked down with the 1st ball of the extra frame : 9 GAME OVER Frame | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | Extra -------+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+------ Ball 1 | 8 | 6 | X | X | 3 | 9 | X | 6 | X | 7 | 9 -------+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+------ Ball 2 | 1 | / | | | 5 | / | | / | | / | -------+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+------ Score | 9 | 29 | 52 | 70 | 78 | 98 | 118 | 138 | 158 | 177 | [103] a.out This is where the greeting goes Write your own version that explains the game of bowling, what this program does, and what is expected of the user Enter # of pins knocked down with the 1st ball of frame 1 : 10 Congratulations, you got a STRIKE !!! Enter # of pins knocked down with the 1st ball of frame 2 : 10 Congratulations, you got a STRIKE !!! Enter # of pins knocked down with the 1st ball of frame 3 : 10 Congratulations, you got a STRIKE !!! Enter # of pins knocked down with the 1st ball of frame 4 : 10 Congratulations, you got a STRIKE !!! Enter # of pins knocked down with the 1st ball of frame 5 : 10 Congratulations, you got a STRIKE !!! Enter # of pins knocked down with the 1st ball of frame 6 : 10 Congratulations, you got a STRIKE !!! Enter # of pins knocked down with the 1st ball of frame 7 : 10 Congratulations, you got a STRIKE !!! Enter # of pins knocked down with the 1st ball of frame 8 : 10 Congratulations, you got a STRIKE !!! Enter # of pins knocked down with the 1st ball of frame 9 : 10 Congratulations, you got a STRIKE !!! Enter # of pins knocked down with the 1st ball of frame 10 : 10 Congratulations, you got a STRIKE !!! Enter # of pins knocked down with the 1st ball of the extra frame : 10 Enter # of pins knocked down with the 1st ball of the extra frame : 10 GAME OVER Frame | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | Extra -------+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+------ Ball 1 | X | X | X | X | X | X | X | X | X | X | 20 -------+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+------ Ball 2 | | | | | | | | | | | -------+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+------ Score | 30 | 60 | 90 | 120 | 150 | 180 | 210 | 240 | 270 | 300 | [104] a.out This is where the greeting goes Write your own version that explains the game of bowling, what this program does, and what is expected of the user Enter # of pins knocked down with the 1st ball of frame 1 : 7 the 2nd ball of frame 1 : 2 Enter # of pins knocked down with the 1st ball of frame 2 : 8 the 2nd ball of frame 2 : 2 You got a SPARE !! Enter # of pins knocked down with the 1st ball of frame 3 : 10 Congratulations, you got a STRIKE !!! Enter # of pins knocked down with the 1st ball of frame 4 : 7 the 2nd ball of frame 4 : 3 You got a SPARE !! Enter # of pins knocked down with the 1st ball of frame 5 : 5 the 2nd ball of frame 5 : 4 Enter # of pins knocked down with the 1st ball of frame 6 : 8 the 2nd ball of frame 6 : 2 You got a SPARE !! Enter # of pins knocked down with the 1st ball of frame 7 : 10 Congratulations, you got a STRIKE !!! Enter # of pins knocked down with the 1st ball of frame 8 : 9 the 2nd ball of frame 8 : 1 You got a SPARE !! Enter # of pins knocked down with the 1st ball of frame 9 : 8 the 2nd ball of frame 9 : 2 You got a SPARE !! Enter # of pins knocked down with the 1st ball of frame 10 : 7 the 2nd ball of frame 10 : 1 GAME OVER Frame | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | Extra -------+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+------ Ball 1 | 7 | 8 | X | 7 | 5 | 8 | X | 9 | 8 | 7 | -------+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+------ Ball 2 | 2 | / | | / | 4 | / | | / | / | 1 | -------+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+------ Score | 9 | 29 | 49 | 64 | 73 | 93 | 113 | 131 | 148 | 156 | [106]

Although your output need not be identical to the above, all information (including the greeting) must be present.

Submitting the Program

Since you must use separate compilation for this project, you will have several files that must be submitted for this project. The source file that contains main() MUST be called proj2.c, the file containing your bowling functions MUST be called bowling.c, and the header file MUST be called bowling.h
To submit your project, type the following at the Unix prompt. Note that the project name starts with uppercase 'P'.

submit cs201 Proj2 proj2.c bowling.c bowling.h

Do NOT forget to submit your bowling.h file. Your program will NOT compile without it.

To verify that your project was submitted, you can execute the following command at the Unix prompt. It will show all files that you submitted in a format similar to the Unix 'ls' command.

submitls cs201 Proj2


CSEE | 201 | 201 S'05 | lectures | news | resources | help |

Tuesday, 08-Mar-2005 09:26:12 EST