Carmenia Bona wrote:This is what I'm getting:...
Carmenia,
A really good idea when you run into problems like this is to
StopCoding (←click).
Then, you have two choices (both of which require a pencil and LOTS of paper):
1. Go through your code and write down,
for each iteration of the loop, the values of each variable. An alternative is to print them all out with
System.out.println() statements.
2. Forget the code altogether and write down
in English (or your native language) the exact steps required to get the result you want; and then check those steps against what you've actually coded.
Personally, I prefer number 2; but the best time to do it is
before you write any Java code at all.
HIH
Winston