Computing.Net > Forums > Programming > Please help with c on bowling probl

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Please help with c on bowling probl

Reply to Message Icon

Name: helpwithcprogramming
Date: June 28, 2003 at 18:07:20 Pacific
OS: Windows Me
CPU/Ram: pent 4/256M
Comment:

Hi really need help with this please. It is supposed to be a program that mimicks score keeping in the game of bowling. I input how many pins on each ball i got. The 10 frame is handled differently if it is a strike or spare. I really need help with getting it to run. The language is C and it is supposed to be simple..nothing more advanced then what is below. Below is the code that I have. Any help will be much appreciated!!


void main ()

{
int i,score[10], ball[2][12];


printf("Hello and Welcome to the Blinn Bowling Center");


//To get input of all balls


for (i = 0; i 10 || ball[0][i] 10 || ball[1][i] 10)
printf("Sorry, Bad input,try again");
else
if (ball[0][i] + ball[1][i] == 10)
printf("Not Bad...Spare!");
else
continue;

if (ball[0][9] == 10)
printf("Please input ball [2][i]: ");
printf("Please input ball [3][i]:");


//Need to figure out score[0] first;

for (i = 1; i 9; i++)
if (ball[0][i] == 10)
if (ball[0][i + 1) == 10)
score[i] = score[i-1] + ball[0][i] + ball[0][i + 1] 
+ ball[0][i + 2];
else
score[i] = score[i - 1] + ball[0][i] + ball[0][i + 
1] + ball[1][i + 1];
else
if (ball[0][i] + ball[1][i] == 10)
score[i] = score[i - 1] + 10 + ball[0][i +1);
else 
score[i] = score[i -1] + ball[0][i] + ball[1][i];

//Handle 10th frame, if it is strike or spare 



Sponsored Link
Ads by Google

Response Number 1
Name: Sord
Date: June 28, 2003 at 23:07:49 Pacific
Reply:

I see a couple problems. In the section:

for (i = 0; i 10 || ball[0][i] 10 || ball[1][i] 10)
printf("Sorry, Bad input,try again");
else
if (ball[0][i] + ball[1][i] == 10)
printf("Not Bad...Spare!");
else
continue;

The for loop should have an i++ should it not?
What is the else before the if with?
Did you want the if included in the for loop? If so,
put a { after the for loop, and a
} at the end of the section to be
included.
Also, I'm not familiar with the continue command,
maybe someone else can help you with that one.


0

Response Number 2
Name: Infinite Recursion
Date: June 30, 2003 at 08:46:12 Pacific
Reply:

This line of code:

for (i = 0; i 10 || ball[0][i] 10 || ball[1][i] 10)

Is missing the conditional operator between the i and the 10, as well as after your arrays (basically, you need a conditional operator to the left of all the 10s in this line of code.

In this line of code:
for (i = 1; i 9; i++)

You are missing the condition between i and 9.

In the next line of code:
if (ball[0][i + 1) == 10)

You are missing a closing ] right where you put the extra ), this should read ....[i+1]...

Same thing in this line of code...
score[i] = score[i - 1] + 10 + ball[0][i +1);

It should read ....[i+1];

You may also need to include a set of { }, depending on how you want your program to operate.

When you accomodate these errors, the continue statement should work itself out.

Hope this helps.

Infinite Recursion



0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Please help with c on bowling probl

Please help with java program. www.computing.net/answers/programming/please-help-with-java-program/14834.html

Urgent: need help with c++ coding www.computing.net/answers/programming/urgent-need-help-with-c-coding/5478.html

need help with c homework www.computing.net/answers/programming/need-help-with-c-homework/4670.html