Write a program that simulates the classic 99 bottles of son
Write a program that simulates the classic \"99 bottles of...\" song.
Your program should take as input from the user the number of bottles to be simulated and the contents of the bottle. Imagine that you are given a crate with the number of bottles to be used.
Because this is a simulation, your program must first set up the wall, by \'placing\' the bottles up there one at a time (output a line for each bottle placed on the wall). Each time, also output the number of bottles left in the crate as well as the number now on the wall.
Then, the program can \'sing\' the song by outputting a line where it \'takes one down, pass(es) it around\' for each bottle. Assume that the guests, after passing around the bottles, simply throw them on the floor; output the number of bottles on the wall and on the floor.
Solution
99 BOTELS OF ... SONG PROGRAMMING : declare integer beers = 99; declare varchar s; while (beers > 0) { if (beers != 1) s = \"s\"; else s = \"\"; printf(\"%d bottle%s of beer on the wall,\ \", beers, s); printf(\"%d bottle%s of beeeeer . . . ,\ \", beers, s); printf(\"Take one down, pass it around,\ \"); beers--; if (beers > 0) printf(\"%d\", beers); else printf(\"No more\"); if (beers != 1) s = \"s\"; else s = \"\"; printf(\" bottle%s of beer on the wall.\ \", s); }