Next: Recurse
Up: Assignment 5: Recursion
Previous: Assignment 5: Recursion
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' can't take one down, ya' can't pass it around,
'cause there are no more bottles of beer on the wall!
And then the song (finally) ends.
- 1.
- Create a new project
called Bottle based on the No Graphics stationery.
Follow the project-creation instructions carefully!
- 2.
- 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.
- 3.
- As you are developing your code, you will probably
want to test it with a small number of verses, like
``3 Bottles of Beer.''
Next: Recurse
Up: Assignment 5: Recursion
Previous: Assignment 5: Recursion
Allen B. Downey
1999-03-01