Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp

Raymond Spiess III

Greenhorn
+ Follow
since May 03, 2007
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Raymond Spiess III

I found my error and just answered my own question. In my head I was processing this statement as true when x = 0 (obviously wrong), which threw off all the other calculations. Doh!

Thanks for everyone's help!

16 years ago
Thanks! This is my first post but already I have learned quite a bit. Not the least of which is the "code" tags. Here is the section that I don't understand. Why doesn't this if statement get processed when x = 3, thus making e2.count = 11?

16 years ago
Thanks, that correction does makes sense. However, I have only gone through the code in my head, I haven't yet compiled anything. My main concern is why do I get 11 when the book says it should be 10. I guess I am trying to follow the logic in my head and can't see how the answer is achieved.

Regards
16 years ago
I am really new to java. I just bought a book that I am going through and there is a puzzle to solve. I have the solution but my output does not match the output the book says it should be. Anyone care to go over this and help explain to me if the book is wrong?

The output should be:
%java EchoTestDrive
helloooo...
helloooo...
helloooo...
helloooo...
10

But I get 11. What am I doing wrong?


EDIT by mw: Added Code Tags.
[ May 03, 2007: Message edited by: marc weber ]
16 years ago