make changes to the program listed down to account for the actual number of days
ID: 3638495 • Letter: M
Question
make changes to the program listed down to account for the actual number of days in each month. if possible, please make sure there are no programming errors when outputting the data...#include <iostream>
using namespace std;
int main()
{
int m,d,y;
cout<<"Enter month: june";
cin>>m;
cout<<"Enter day: 20";
cin>>d;
cout<<"Enter year: 2012";
cin>>y;
cout<<"The day after "<<m<<"/"<<d<<"/"<<y<<" is: 21";
d++;
if(d>30)
{d=1;
m++;
if(m>12)
{m=1;
y++;
}
}
cout<<m<<"/"<<d<<"/"<<y<<endl;
system("pause");
return 0;
}
Explanation / Answer
Hi, my friend here is a full program outputting the next date if u need more help message me PLEASE RATE #include #include using namespace std; #define TRUE 1 #define FALSE 0 using namespace std; class mydate{ int day; int month; int year; public: void readdate(); int isLeapYear(); string month2string(); int exceedsDaysInMonth(); void tommorow(); }; // Input date from user void mydate::readdate(){ cout > day; cout > month; cout > year; } // make sure month days are correct // return TRUE if days exceeds in a month int mydate::exceedsDaysInMonth(){ int days[] = {31,28,31,30,31,30,31,31,30,31,30,31}; if ( month < 1 || month > 12 || day > days[month-1]) return TRUE; else return FALSE; } // convert numeric month into string string mydate::month2string(){ char *months[] = {"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"}; if ( exceedsDaysInMonth() ) { if ( ! (month < 1 || month > 12) ) return months[month-1]; else return "Unknown month"; } else return "Unknown month"; } // return TRUE if a year is leap int mydate::isLeapYear(){ if ( (year % 4) != 0 ){ return FALSE; } else if ( (year % 400) != 0 ){ return TRUE; } else if ( (year % 100) == 0 ){ return FALSE; } else { return FALSE; } } // validate and calculate tommorows date void mydate::tommorow(){ int td, tm, ty; int days[] = {31,28,31,30,31,30,31,31,30,31,30,31}; if ( year < 0 ){ cerrRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.