Techware Labs Header

Forums have moved

See this announcement for more details, or just go directly there.

  #1  
Old 02-26-2003, 12:02 PM
Sparkz
 
Posts: n/a
Default 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
Reply With Quote
  #2  
Old 02-28-2003, 12:50 PM
Propig
 
Posts: n/a
Default

I think your problem is on this line

cout << "On the " << euph;

it should look more like

cout << "On the " << euph << endl;
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 03:27 PM. Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Forum style by ForumMonkeys.