# Re: Learn to Program, by Chris Pine

How’s this for a solution. Note I tried to only use constructs covered
up to the point of the exercise in the book.

numBottles = 99
while numBottles > 2
puts numBottles.to_s + " bottles of beer on the wall, " +
numBottles.to_s + " bottles of beer,"
puts “take one down, pass it around, " + (numBottles-1).to_s + "
bottles of beer on the wall!”
puts “”
numBottles = numBottles - 1
end
puts numBottles.to_s + " bottles of beer on the wall, " +
numBottles.to_s + " bottles of beer,"
puts “take one down, pass it around, " + (numBottles-1).to_s + " bottle
of beer on the wall!”
puts “Yay!”

–Bill

William (Bill) Froelich wrote:

numBottles = numBottles - 1
end
puts numBottles.to_s + " bottles of beer on the wall, " +
numBottles.to_s + " bottles of beer,"
puts “take one down, pass it around, " + (numBottles-1).to_s + " bottle
of beer on the wall!”
puts “Yay!”

–Bill

Wow! It was so simple once I saw how it should/could be done! I’d (for
some
reason) completely forgot to do the ‘+ +’ thing in a ‘puts’!
I’m
terrible at learning things, having severe ADHD, so if you don’t tire of
helping me, I won’t tire of still trying to learn programming.

One question though about something that’s got me still a little
confused.
Why the ‘while numBottles > 2’ ?

Anyway, I really do appreciate the help Bill! Thank you very much!

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.