Need some C++ help
Hey, i really need some C++ help. I use DevCPP, in case anyone was wonmdering..
I needed to make a program that displayed the 12 days of christmas song, in a way similar to this:
on the 1st day blah blah,
a partridge in a pear tree.
on the second day,
whatever comes 2nd,
and a partridge
(NOTE THE CARRAIGE RETURNS, AND NICE SPACING).
My current code just displays each day's text as 1 line (except for the 'on the whatever day part).
Can someone help me out??
Heres my code:
//lab10B0
#include <conio.h>
#include <iostream.h>
#include <iomanip.h>
#include <string>
void main()
{
int whatday;
int firsttime1 = 0;
string onthisday = "", temponthisday = "", euph = "first";
for (whatday = 1; whatday <= 12; whatday++)
{
switch(whatday)
{
case 1 : onthisday = onthisday + "A partridge in a pear tree.";
temponthisday = "and a partridge in a pear tree.";
cout << "On the " << euph;
cout << " day of Christmas, my true love gave to me, " << endl;
cout << onthisday << endl;
getche();
case 2 : onthisday = "Two turtledoves, " + temponthisday;
temponthisday = onthisday;
euph = "second";
cout << "On the " << euph ;
cout << " day of Christmas, my true love gave to me, " << endl;
cout << onthisday << endl;
getche();
case 3 : onthisday = "Three French hens, " + temponthisday;
temponthisday = onthisday;
euph = "third";
cout << "On the " << euph ;
cout << " day of Christmas, my true love gave to me, " << endl;
cout << onthisday << endl;
getche();
case 4 : onthisday = "Four calling birds, " + temponthisday;
temponthisday = onthisday;
euph = "fourth";
cout << "On the " << euph ;
cout << " day of Christmas, my true love gave to me, " << endl;
cout << onthisday << endl;
getche();
case 5 : onthisday = "Five gold rings (Insert Trumpet Noise Here!), " + temponthisday;
temponthisday = onthisday;
euph = "fifth";
cout << "On the " << euph ;
cout << " day of Christmas, my true love gave to me, " << endl;
cout << onthisday << endl;
getche();
case 6 : onthisday = "Six geese a-laying, " + temponthisday;
temponthisday = onthisday;
euph = "sixth";
cout << "On the " << euph ;
cout << " day of Christmas, my true love gave to me, " << endl;
cout << onthisday << endl;
getche();
case 7 : onthisday = "Seven swans a-swimming, " + temponthisday;
temponthisday = onthisday;
euph = "seventh";
cout << "On the " << euph ;
cout << " day of Christmas, my true love gave to me, " << endl;
cout << onthisday << endl;
getche();
case 8 : onthisday = "Eight maids a-milking, " + temponthisday;
temponthisday = onthisday;
euph = "eighth";
cout << "On the " << euph ;
cout << " day of Christmas, my true love gave to me, " << endl;
cout << onthisday << endl;
getche();
case 9 : onthisday = "Nine ladies waiting, " + temponthisday;
temponthisday = onthisday;
euph = "ninth";
cout << "On the " << euph ;
cout << " day of Christmas, my true love gave to me, " << endl;
cout << onthisday << endl;
getche();
case 10 : onthisday = "Ten lords a-leaping, " + temponthisday;
temponthisday = onthisday;
euph = "tenth";
cout << "On the " << euph ;
cout << " day of Christmas, my true love gave to me, " << endl;
cout << onthisday << endl;
getche();
case 11 : onthisday = "Eleven pipers piping, " + temponthisday;
temponthisday = onthisday;
euph = "eleventh";
cout << "On the " << euph ;
cout << " day of Christmas, my true love gave to me, " << endl;
cout << onthisday << endl;
getche();
case 12 : onthisday = "Twelve drummers drumming, " + temponthisday;
temponthisday = onthisday;
euph = "twelfth";
cout << "On the " << euph ;
cout << " day of Christmas, my true love gave to me, " << endl;
cout << onthisday << endl;
break;
}
}
}
thanks!
-em
|