Apr 2, 2015 at 4:37pm UTC
#include <iostream>
#include <string>
#include <cmath>
// structure for date format
struct date{
int month, day, year;}; date today, next;
using namespace std;
int main()
{
cout<<"Please enter current month"<<endl;
cin>>today.month;
cout<<"\nPlease enter current day"<<endl;
cin>>today.day;
cout<<"\nPlease enter current year"<<endl;
cin>>today.year;
int type, Ndays;
if(today.month > 12 || today.month < 1)
cout<< " Invalid month!";
else if(today.day > 31 || today.day < 1)
cout<<"Invalid day!";
else if(today.year < 1)
cout<<"invalid year";
if(today.year%400==0 || today.year%100==0)
{
type = 1;
cout<< "\nThe year is leap year.";
}
else
{
type = 0;
cout<< "\nThe year is not a leap year.";
}
while (today.month <= 12)
{
switch (today.month)
{
case 1:
cout << "\n\nJanuary\n" << endl;
Ndays = 31;
break;
case 2:
cout << "\n\nFebruary\n" << endl;
if (type = 1)
{
Ndays = 29;
}
else
{
Ndays = 28;
}
break;
case 3:
cout << "\n\nMarch\n" << endl;
Ndays = 31;
break;
case 4:
cout << "\n\nApril\n" << endl;
Ndays = 30;
break;
case 5:
cout << "\n\nMay\n" << endl;
Ndays = 31;
break;
case 6:
cout << "\n\nJune\n" << endl;
Ndays = 30;
break;
case 7:
cout << "\n\nJuly\n" << endl;
Ndays = 31;
break;
case 8:
cout << "\n\nAugust\n" << endl;
Ndays = 31;
break;
case 9:
cout << "\n\nSeptember\n" << endl;
Ndays = 30;
break;
case 10:
cout << "\n\nOctober" << endl;
Ndays = 31;
break;
case 11:
cout << "\n\nNovember" << endl;
Ndays = 30;
break;
case 12:
cout << "\n\nDecember\n" << endl;
Ndays = 31;
break;
default:
;
}
}
date next = today;
next.day + 7
cout<<"Todays date one week in the future is" << date next <<endl;
return 0;
}
Apr 2, 2015 at 4:55pm UTC
Please use code tags for all of your code, its under the format section and looks like this <>. Mark all of your code and press it.
next.day + 7
Missing semicolon.
cout<<"Todays date one week in the future is" << date next <<endl;
I dont know what you're trying to cout here. date next? whats that?
you use next to get to things in your structure. next.day, next.year etc.