"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.
"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.
"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.
No. That won't compile. == 0 might be better, but I haven't looked at the code enough to know.alex lesta wrote: . . . else if (beerNum = 0 ) . . .]
Prasanna Kumaar wrote:following piece of code wont get executed at all
if (beerNum == 1){
word = "bottle"; // singular
}
so even if only one bottle of beer is remaining "1 bottles of beer on the wall" will be printed...'bottles' wont be replaced by 'bottle'
Prasanna Kumaar wrote:so should this condition be at the end of the program.
if (beerNum == 1){
word = "bottle"; // singular {
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
If you want to reach the stars, then divide and conquer
Carlo Lopez wrote:I have executed your program, but changing the number of bottles to 2, and changing some of the code to make it more explicit:
the output is:
2 bottles of beer on the wall
2 bottles of beer
Take one down.
Pass it around
1 bottle of beer on the wall
1 bottle of beer
Take one down.
Pass it around
No more bottles of beer on the wall
what you have to understand here is the iteration, that I think you are understanding, it goes in function of the "index" of the iteration, 'beerNum' in this case.
Try to change the value of 'beerNum', or the index you use, when you don't understand the output.
alex lesta wrote:THANK YOU
Carlo Lopez wrote:I have executed your program, but changing the number of bottles to 2, and changing some of the code to make it more explicit:
the output is:
2 bottles of beer on the wall
2 bottles of beer
Take one down.
Pass it around
1 bottle of beer on the wall
1 bottle of beer
Take one down.
Pass it around
No more bottles of beer on the wall
what you have to understand here is the iteration, that I think you are understanding, it goes in function of the "index" of the iteration, 'beerNum' in this case.
Try to change the value of 'beerNum', or the index you use, when you don't understand the output.
THANKS FOR THE INFO, IT WORKED
Campbell Ritchie wrote:Carlo Lopez: welcome to the Ranch
If you want to reach the stars, then divide and conquer
Carlo Lopez wrote:Hey carlos, I am reading to books on Java. Head First java and Just java 2. In your opinion are these books good enough for me to learn java.
alex lesta wrote:
Carlo Lopez wrote:Hey carlos, I am reading to books on Java. Head First java and Just java 2. In your opinion are these books good enough for me to learn java.
Thank you!![]()
If you want to reach the stars, then divide and conquer
Carlo Lopez wrote:[
I would suggest "Core Java, Volume 1" from Horstman, excellent book.
SCJP 6. Learning more now.
Consider Paul's rocket mass heater. |