Yes, and thanks. I also found the other flaw put there by the author:
code:
if (beerNum == 1) {
word = "bottle"; //single bottle of beer
}
should come after...
code:
beerNum = beerNum - 1;
Campbell Ritchie wrote:Welcome to the Ranch
Any point in answering a three‑year‑old thread?
Robert Archer wrote:public static void main(String args[])
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
}
Ivan Addeo wrote:I'm reading this book now, i discovered that the lyrics of the song're "99 bottles of beer on the wall / 99 bottles of beer. / Take one down / Pass it around".
But in the book's program the string "bottles of beer on the wall" is repeated two times. So i modified the program in this way:
Joanne
Joanne Neal wrote:
Ivan Addeo wrote:I'm reading this book now, i discovered that the lyrics of the song're "99 bottles of beer on the wall / 99 bottles of beer. / Take one down / Pass it around".
But in the book's program the string "bottles of beer on the wall" is repeated two times. So i modified the program in this way:
It should be repeated twice. The first line of each verse is the same as the last line of the previous verse.
99 bottles of beer on the wall
99 bottles of beer.
Take one down
Pass it around
98 bottles of beer on the wall
98 bottles of beer on the wall
98 bottles of beer.
Take one down
Pass it around
97 bottles of beer on the wall
97 bottles of beer on the wall
97 bottles of beer.
Take one down
Pass it around
96 bottles of beer on the wall
etc.
}
Ivan Addeo wrote:But the program in the book has not this output.. how should be the code?
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Winston Gutkowski wrote:
Ivan Addeo wrote:But the program in the book has not this output.. how should be the code?
Ivan,
Don't worry about it. Write the program as you've been asked to.
And "how should be the code?" is one question we will not answer. We will help you to write it; but we won't do it for you.
So: forgetting that extra line, does your program work?
Winston
}
Raymond Gillespie wrote:Take a look at these to snippets.
The while loop only runs when the variable is greater than zero.
}
Ivan Addeo wrote:Yes, but the program do the subtraction '1-1' and than output "0 bottle of beer on the wall" and after "No more[...]".
I'm working on a solution
luck, db
There are no new questions, but there may be new answers.
Darryl Burke wrote:
Ivan Addeo wrote:Yes, but the program do the subtraction '1-1' and than output "0 bottle of beer on the wall" and after "No more[...]".
I'm working on a solution
Hint: MessageFormat
}
}
Ivan Addeo wrote:I read, but i'm still confused I don't want the "0 bottle" output, but only the "No more[...]".
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
hey buddy you are using the first if in the wrong way..mirko ninja wrote:I'm new to Java. Here is my lite contribution
Learning starts with a question and continues with a discovery Stay hungry for knowledge.
sandy nambi wrote:
hey buddy you are using the first if in the wrong way..mirko ninja wrote:I'm new to Java. Here is my lite contribution
Campbell Ritchie wrote:Move line 21 after the end of the while (beerNum > 0) loop.
Hey, check out my mega multi devastator cannon. It's wicked. It makes this tiny ad look weak:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
|