# Thread: Need help with a bowling program...

1. ## Need help with a bowling program...

So I have to calculate the final score for a bowling game with 5 frames. I know how the bowling score system works, but I am little confused on how I should write the code. I know I will have to use some ifs but I don't really know how to start it. Sorry I'm a beginner, any tips?

2. Figure out how you keep score. If you had to explain to a very patient but dense person how to keep score in bowling, how would you do it? Write down the steps as you would explain them. Make sure that all cases are covered.

Once you know the logic, coding it is trivial.

(Also, bonus hint: be sure you know what the input is going to look like -- all numbers, or with 'X' and '/' etc.)

3. I agree with the advice above but i suggest you stick to just using numbers to represent everything on the scorecard at first, graphical representation can come once you have the routine working and know a bit more about writing your code.
i would use an array for each player with three elements (spaces to store scores) each element will hold the value of the score for each delivery of the ball per frame, (use three elements from the start just to cover the final frame which i believe has max of three shots at the pins)

here's some example code fragments for ideas.

Code:
```/*here are some ideas for variables you might need.....*/

/* these are your arrays to hold the score from each delivery of the ball for your player */

int player1[3];

/* this holds the score between frames because i believe it is not updated until following frame? * /

int lastframescore1 = 0;

/* this for getting the scores from pins just knocked down latest frame */

int currentframescore1 = 0;

/* this are for bonuses from last round(lastframescore) added to currentframescore */

int totalframescore1 = 0;

/* these for the running game totals */
int totalgamescore1 = 0;

/* frame + shot counter */

int frame = 0;
int shot = 0;

/* variable to hold number of pins knocked over */

int pinsdown = 0;

/*Now an example of how you might use those arrays in a game loop */

while(frame < 5)
{

while(shot < 2)                         /*starts from 0 so 0, then 1 is two shots */
{

/* your game code to play the shot here, maybe using random number that you can 'weight' favourably or unfavourably depending on the player 'skill' * the result of the play is stored in 'pinsdown = ....' */

player1[shot] = pinsdown;
lastframescore = lastframescore  + player1[shot];

shot ++;                                   /* shot = shot + 1, i.e next loop */

}

currentframescore = currentframescore + lastframescore;

shot = 0;                                        /* reset for next loop */
lastframescore = 0;                        /* reset for next scores */

frame++;
}```
I have not got time to fill all this in here or use all the variables i listed, but i think you should be able to get some tips from this, good luck!