Hello,newbie here,i wan 2 write a program 2 determine the day after sum day.Example:like we input monday,then we input 10 ,then d program wil cum out wf thursday.i hv ald write d code,but it hv error but i duno where r d error.i hv write d program in 3 document,they include a header file,a implementation file,a main program.Plz help me....thnx in advance.
[quote]
CODE
header file
_______________:
#include<iostream>
#include<string>
class dayType
{
public:
void setDay(string day,int num);
void printDay(string day,int num);
void returnTheDay(string after);
void returnNextDay(string day);
void returnPreviousDay(string day);
private:
int num;
};
CODE
implementation file
________________:
#include<iostream>
#include<string>
#include"day.h"
using namespace std;
void dayType::setDay(string day,int num)
{
cout<<"Enter a day like 'sunday'/'monday'...etc ";
cin>>day;
cout<<endl;
cout<<"Key in a number of day "
cin>>num;
cout<<endl;
}
void dayType::printDay(string day,int num)
{
cout<<"Today is "<<day<<"after "<<num
<<"the day is "<<after;
cout<<endl;
}
void dayType::returnTheDay(string day)
{
else if (day==sunday)
{
return 7;
}
else if (day==monday)
{
return 1;
}
else if (day==tuesday)
{
return 2;
}
else if (day==wednesday)
{
return 3;
}
else if (day==thursday)
{
return 4;
}
else if (day==friday)
{
return 5;
}
else if (day==saturday)
{
return 6;
}
after=day+num;
switch(after)
{
case '1':
cout<<"monday";
cout<<end;
break;
case '2':
cout<<"tuesday";
cout<<endl;
break;
case '3':
cout<<"wednesday";
cout<<endl;
break;
case '4':
cout<<"thursday";
cout<<endl;
break;
case '5':
cout<<"friday";
cout<<endl;
case '6':
cout<<"saturday";
cout<<endl;
case '7':
cout<<"sunday";
cout<<endl;
}
}
void dayType::returnNextDay(string day)
{
if (day==sunday)
{
cout<<"The next day is monday ";
cout<<endl;
}
if (day==monday)
{
cout<<"The next day is tuesday ";
cout<<endl;
}
if (day==tuesday)
{
cout<<"The next day is wednesday ";
cout<<endl;
}
if (day==wednesday)
{
cout<<"The next day is thursday ";
cout<<endl;
}
if (day==thursday)
{
cout<<"The next day is friday ";
cout<<endl;
}
if (day==friday)
{
cout<<"The next day is saturday ";
cout<<endl;
}
if (day==saturday)
{
cout<<"The next day is sunday ";
cout<<endl;
}
}
void dayType::returnPreviousDay(string day)
{
if (day==sunday)
{
cout<<"The previous day is saturday ";
cout<<endl;
}
if (day==monday)
{
cout<<"The previous is sunday ";
cout<<endl;
}
if (day==tuesday)
{
cout<<"The previous is monday ";
cout<<endl;
}
if (day==wednesday)
{
cout<<"The previous is tuesday ";
cout<<endl;
}
if (day==thursday)
{
cout<<"The previous is wednesday ";
cout<<endl;
}
if (day==friday)
{
cout<<"The previous is thursday ";
cout<<endl;
}
if (day==saturday)
{
cout<<"The next day is friday ";
cout<<endl;
}
CODE
main program
_____________:
#include<iostream>
#include<string>
#include"day.h"
using namespace std;
void dayType();
int main()
{
setDay(string day,int num)
cout<<endl;
returnTheDay(string after)
cout<<endl;
printDay(string day,int num)
cout<<endl;
returnNextDay(string name)
cout<<endl;
returnPreviousDay(string day)
cout<<endl;
return 0;
}
Can u tell me where r d syntax error?i reali duno
This post has been edited by prescott2006: 20 Jan, 2008 - 09:28 AM