LAB 04B - BOTTLES

Concepts

To gain practice with for loops, and see how easy it is to automate a repetitive task.

Your task for this lab is to write a program that displays similar lyrics to the classic song 99 Bottles of Beer on the Wall. Despite the light-heartedness of this example, the goal is to realize that it's easier to automate such repetitive tasks than it is to accomplish them explicitly or manually.

Instructions

This will be a new project. Create one and call it Lab04B. (Your solution to this Lab will be submitted with Homework 04.)

Your program should prompt the user for the number of bottles they would like to start with and then display the lyrics of the song. The following is a sample execution of the finished program (the '100' on the first line is typed by the user and the '. . .' in the middle would be replaced by all of the lyrcis not shown):

Hello, I'd like to sing you a song.
Enter a number: 100
100 bottles of hand sanitizer on the wall,
100 bottles of hand sanitizer!
Take 1 down, pass it around,
99 bottles of hand sanitizer on the wall!

99 bottles of hand sanitizer on the wall,
99 bottles of hand sanitizer!
Take 1 down, pass it around,
98 bottles of hand sanitizer on the wall!

...

1 bottle of hand sanitizer on the wall,
1 bottle of hand sanitizer!
Take 1 down, pass it around,
0 bottles of hand sanitizer on the wall!
Press any key to continue . . .

We encourage you to use the "Incremental Build" model. This is a software development methodology where the model is designed, implemented, and tested incrementally, adding a little more functionality each time, until the product is finished. In other words, write a small amount of code to do one specific task, then run the program to be sure what you have done so far works. You move on to the next part of the program only when you are satisfied that your current code works.

In this program, you should start by writing a program that reads a value from the user and then prints that value to the console. Once that works, then you should write a loop that prints all of the numbers from the value entered down to zero. Finally, you should add the full song lyrics.

Note that when 1 bottle is left, the song prints "1 bottle" and not "1 bottles." (Add this feature as the last thing you implement -- get the basics working first.)

Once you have your program working, you should try to break it. What happens when you enter 1000000000000000 bottles? What happens when you enter a negative number? Or a letter? Or a word? What do you think causes these problems? You don't need to fix these issues, just notice the weaknesses in your program.