Answer to Question #4275 in C++ for motunrayo
c++ program on a calender
1
2011-10-14T11:24:22-0400
// calendar.cpp : Defines the entry point for the console application.
//
//calendar 2011
#include <iostream>
using namespace std;
int main()
{
int DayInMon;
int DayWeek = 6; //2011 year beginning in saturday, 6 day
for (int i=1; i<=12; i++)
{
& switch(i)
& {
& case 1:
& cout<<"\t\t\tJanuary"<<endl;
& DayInMon = 31;
& break;
& case 2:
& cout<<"\t\t\tFebruary"<<endl;
& DayInMon = 28;
& break;
& case 3:
& cout<<"\t\t\tMarch"<<endl;
& DayInMon = 31;
& break;
& case 4:
& cout<<"\t\t\tApril"<<endl;
& DayInMon = 30;
& break;
& case 5:
& cout<<"\t\t\tMay"<<endl;
& DayInMon = 31;
& break;
& case 6:
& cout<<"\t\t\tJune"<<endl;
& DayInMon = 30;
& break;
& case 7:
& cout<<"\t\t\tJuly"<<endl;
& DayInMon = 31;
& break;
& case 8:
& cout<<"\t\t\tAugust"<<endl;
& DayInMon = 31;
& break;
& case 9:
& cout<<"\t\t\tSeptember"<<endl;
& DayInMon = 30;
& break;
& case 10:
& cout<<"\t\t\tOktober"<<endl;
& DayInMon = 31;
& break;
& case 11:
& cout<<"\t\t\tNowember"<<endl;
& DayInMon = 30;
& break;
& case 12:
& cout<<"\t\t\tDecember"<<endl;
& DayInMon = 31;
& break;
&
& }
& cout<<"Mo\t Tu\t We\t Th\t Fr\t Sa\t Su\t"<<endl; //days names
& for(int k=1;k<DayWeek;k++) & //its need for to correct days tab, when month beginning
& {
& cout<<"\t";
& }
& for(int g=1; g<=DayInMon; g++) & // show days
& {
& cout<<g<<"\t";
&
& if(DayWeek%7==0) & // tab days by week
& {
& cout<<endl;
& DayWeek=0;
& }
& DayWeek++;
& }
&
& cout<<"\n\n";
&
}
system("pause");
return 0;
}
Need a fast expert's response?
Submit order
and get a quick answer at the best price
for any assignment or question with DETAILED EXPLANATIONS!
Learn more about our help with Assignments:
C++
Comments
Leave a comment