Question: Exercise 4 . 5 There is an old song about beer bottles that can be expressed recursively. The first verse of the song 9 9

Exercise 4.5 There is an old song about beer bottles that can be expressed
recursively.
The first verse of the song 99 Bottles of Beer is:
99 bottles of beer on the wall, 99 bottles of beer, ya take one down, ya
pass it around, 98 bottles of beer on the wall.
Subsequent verses are identical except that the number of bottles gets smaller by one
in each verse, until the last verse:
No bottles of beer on the wall, no bottles of beer, ya cant take one down,
ya cant pass it around, cause there are no more bottles of beer on the
wall!
And then the song (finally) ends.
Write a program that prints the entire lyrics of 99 Bottles of Beer. Your program
should include a recursive method that does the hard part, but you also might want
to write additional methods to separate the major functions of the program.
The last verse, when the number of bottles left is 0, is the base case. The other verses
are the recursive step.
As you are developing your code, you will probably want to test it with a small number
of verses, like 3 Bottles of Beer.
The purpose of this exercise is to take a problem and break it into smaller problems,
and to solve the smaller problems by writing simple, easily-debugged methods.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!