Working on an assignment to allow a user to input the number of beers they have left on the wall, and the program will finish the lyrics.
I've made it work, however, my professor wants it to display "No more beers on the wall" when it reaches 0, instead of actually saying 0 beers on the wall.
My current code shows " No more beers on the wall" at the end, however, it still displays the 0.. and I can't make the 0 disappear. Any help? thank you very much.
#include <iostream>
#include <string>
#include <cstdlib>
#include <ctime>
usingnamespace std;
int main()
{
int bottles;
int noBottles = 0;
cout << "Please enter the number of beers on the Wall between 1 - 99. " << endl;
cin >> bottles;
while( bottles > 99 || bottles < noBottles)
{
cout << "Invalid Response. Please enter a number of beers between 1-99 " << endl;
cin >> bottles;
}
while ( bottles > noBottles )
{
cout << bottles << " bottle(s) of beer on the wall," << endl;
cout << bottles << " bottle(s) of beer." << endl;
cout << "Take one down, pass it around," << endl;
cout << --bottles << endl;
if (bottles == noBottles)
{
cout << "No more bottles of beer on the wall" << endl;
}
else
{
cout << " bottle(s) of beer on the wall." << endl;
}
}
return 0;
}