Home CPSC 220

N Bottles of Beer

 

Objective

To get more practice with using loops and conditions.
 

Task

Your task for this lab is to write a program to generate the lyrics to the song "99 Bottles of Beer". However, your program should read in the starting number of bottles the user wants in the song, it won't always be 99.
 

Details


 

Sample Run

Below is a sample run of the program. Values entered by the user are shown in bold face.


Enter the number of bottles to start with: 5
5 bottles of beer on the wall, 5 bottles of beer.
Take one down and pass it around, 4 bottles of beer on the wall.

4 bottles of beer on the wall, 4 bottles of beer.
Take one down and pass it around, 3 bottles of beer on the wall.

3 bottles of beer on the wall, 3 bottles of beer.
Take one down and pass it around, 2 bottles of beer on the wall.

2 bottles of beer on the wall, 2 bottles of beer.
Take one down and pass it around, 1 bottle of beer on the wall.

1 bottle of beer on the wall, 1 bottle of beer.
Take one down and pass it around, 0 bottles of beer on the wall.

0 bottles of beer on the wall, 0 bottles of beer.
Go to the store and buy some more, 5 bottles of beer on the wall.

 

Submitting

When your program works, email the code to ifinlay@umw.edu.

Copyright © 2024 Ian Finlayson | Licensed under a Creative Commons BY-NC-SA 4.0 License.