Hi, I'm new here and also new in java. I'm reading Head First Java second edition and
arrived at exercise 99 Bootes of beer. I wrote this code but the output isn't correct. Can anyone explain
to me why isn't working as expected ( x doesn't take value 100 and then degrease by 1 , but it take value 0 and then decreases)
It's a good idea to tell us what's not working to your expectations. It's explained in our FAQ under: TellTheDetails ⇐ (Click here). In this case, I think I can guess that the numbers are going down faster than you want them to. Is that right? You are subtracting from x too often. Just once in the loop is enough.
A similar question has already been asked here so you might find some useful information there.
The quieter you are, the more you are able to hear.
Joined: Dec 11, 2012
Thanks for quick replies.
I realized that i made an stupid mistake, The command should have been inside while brackets
Kemal Sokolovic I saw that post but I tried to make it shorter and achive the same result. Now it is working as it should.