I'm new to programming and here is my assignment.
Problem:
Write a program that outputs all 99 stanzas of the "Ninety-Nine Bottles of
Beer on the Wall" song. Your program should print the number of bottles in
English, not as a number:
Ninety-nine bottles of beer on the wall,
Ninety-nine bottles of beer,
Take one down, pass it around,
Ninety-eight bottles of beer on the wall.
...
One bottle of beer on the wall,
One bottle of beer,
Take one down, pass it around,
Zero bottles of beer on the wall.
Your program should not use ninety-nine different output statements!
The program shouldn't ask a user to input a number between 1 and 99. it is supposed to just display the saying in only words from ninety-nine to zero. this is what I have so far and I know this part is right since the professor helped me with it. I am stuck on the for part. How to I display the all the numbers that wrote? I know I don't know what to put for cout? Any help is appreciated. Also I know the program is not finished, I'm trying to show the numbers as words first before I add the saying.
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
|
#include <iostream>
#include <cstring>
using namespace std;
string tens(int x){
switch(x) {
case 9: return "Ninety"; break;
case 8: return "Eighty"; break;
case 7: return "Seventy"; break;
case 6: return "Sixty"; break;
case 5: return "Fifty"; break;
case 4: return "Forty"; break;
case 3: return "Thirty"; break;
case 2: return "Twenty"; break;
case 1: return ""; break;
case 0: return ""; break;
}}
string ones(int x){
switch(x) {
case 9: return "Nine"; break;
case 8: return "Eight"; break;
case 7: return "Seven"; break;
case 6: return "Six"; break;
case 5: return "Five"; break;
case 4: return "Four"; break;
case 3: return "Three"; break;
case 2: return "Two"; break;
case 1: return "One"; break;
case 0: return ""; break;
}}
int main(void)
{
int ones, tens;
for ( int i = 99; i>= 20; i--){
ones = i % 10;
tens = i / 10;
cout<<
return 0;
}
}
|