Draw your flow chart first...
iamthwee
Posting Expert
5,950 posts since Aug 2005
Reputation Points: 1,543
Solved Threads: 439
If you learnt how to draw a flow chart you could then use that to convert into code.
Flow charts help to visualise how problems such as these are solved.
iamthwee
Posting Expert
5,950 posts since Aug 2005
Reputation Points: 1,543
Solved Threads: 439
what are the errors. maybe you need to add braces { and } around lines 21, 22 and 23 to make them all part of the loop.
Ancient Dragon
Retired & Loving It
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
It's almost impossible to help you any further without giving you the actual answer.
Have you drawn a flow chart yet like I said.
iamthwee
Posting Expert
5,950 posts since Aug 2005
Reputation Points: 1,543
Solved Threads: 439
Yes I did
If you have a flow chart you can add it as an attachment for me to look at. (It doesn't have to be neat, just readable)
iamthwee
Posting Expert
5,950 posts since Aug 2005
Reputation Points: 1,543
Solved Threads: 439
shannonpaul:
Control loops come in three varieties: for, while, and do/while. Each loop has one or more keywords (telling what type of loop it is), a body (usuallly telling what to do each time through the loop), and a conditional (indicating when or how often or how many times the body should be done). These loops are used when you want chunks of your program to be repeated a specified number of times.
In order to be syntactically correct a for loop conditional is enclosed in parethesis immediately after the keyword for. The conditional of a for loop needs to know where to start, when to stop and how to change a given variable, in that order; though one, two or all three items may be empty. In additon there should be a semicolon between the first and second and between the second and third item of the conditional. That means if each part of the conditional is empty then there should still be 2 semicolons in the parenthesis.
The body of the for loop occurs after the closing parenthesis of the conditional. If the body of the for loop isn't contained in curly brackets, then only the first statement after the conditional is considered to be the body.
In the code as posted I only notice a single item and no semicolons in the parentheses after the keyword for. Thus, this is an error on several accounts.
Lerner
Nearly a Posting Maven
2,382 posts since Jul 2005
Reputation Points: 739
Solved Threads: 396
for(int num = num1 + num2);
what you are doing here is creating an infinite cycle, that actually does nothing (i bet it doesn't even work)... what you want to do is:
for (int i=0;i<54;i++){
/*procedure*/;
}
remember to open afor loop with curly braces '{' and to close it with '}'... if you write a for loop with ';' it will show you an error...
Nichito
Posting Virtuoso
1,602 posts since Mar 2007
Reputation Points: 424
Solved Threads: 57