Hello, I'm a beginner so im having some difficulty formatting my calendar. My problem is that I can't make the day that the user enters for the first day January 1 fall on to match on the calendar, it automatically aligns it to the left, even if it says it start on Wednesday. I know I must indicate Sunday =0, Monday =1, and so on but how does the computer know I want in specific positions? I was also thinking to just align everything to the right so that the first line of each month can align correctly, since the numbers are correct already..
system ("pause");
return 0;
}
void getYear (int& year)
{
cout<<"Enter a year: ";
cin>>year;
cout<<endl;
}
void weeklyInfo (int& specialDay)
{
cout<<"Enter the the day January 1 falls on..."
<<"\nPress 0 for Sunday, 1 for Monday, 2 for Tuesday,"
<<"\n3 for Wednesday, 4 for Thursday, 5 for Friday, and 6 for Saturday: ";
cin>>specialDay;
cout<<endl;
}
void printCalendar (int& month,int& days, int usedYear,int chosenDay)
{
int counter;
counter=chosenDay;
while (month<=12)
{
cout<<" "<<usedYear<<endl;
int day;
day=0;
for (month=1;month<=12;month++)
{
switch (month)
{
case 1: cout<<"\n January"<<endl;
days=31;
break;
case 2: cout<<"\n February"<<endl;
days=28;
break;
case 3: cout<<"\n March"<<endl;
days=31;
break;
case 4: cout<<"\n April"<<endl;
days=30;
break;
case 5: cout<<"\n May"<<endl;
days=31;
break;
case 6: cout<<"\n June"<<endl;
days=30;
break;
case 7: cout<<"\n July"<<endl;
days=31;
break;
case 8: cout<<"\n August"<<endl;
days=31;
break;
case 9: cout<<"\n September"<<endl;
days=30;
break;
case 10:cout<<"\n October"<<endl;
days=31;
break;
case 11:cout<<"\n November"<<endl;
days=30;
break;
case 12:cout<<"\n December"<<endl;
days=31;
break;
}
int position;
for (position=0;position<=6;position++)
{
switch(position)
{
case 0: cout<<"S";
break;
case 1: cout<<" M";
break;
case 2: cout<<" T";
break;
case 3: cout<<" W";
break;
case 4: cout<<" T";
break;
case 5: cout<<" F";
break;
case 6: cout<<" S"<<endl;
break;
}
}
for (day=1;day<=days;day++)
{
cout<<left<<setw(3)<<day;
if (counter==6)
{
cout<<endl;
counter=0;
}
else
counter=counter+1;
}
cout<<endl;
}
}
}
/*
Program for Yearly Calendars
Enter a year: 1900
Enter the the day January 1 falls on...
Press 0 for Sunday, 1 for Monday, 2 for Tuesday,
3 for Wednesday, 4 for Thursday, 5 for Friday, and 6 for Saturday: 1
1900
January
S M T W T F S
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31
February
S M T W T F S
1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28
March
S M T W T F S
1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31
April
S M T W T F S
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30
May
S M T W T F S
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31
June
S M T W T F S
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
July
S M T W T F S
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31
August
S M T W T F S
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
September
S M T W T F S
1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30
October
S M T W T F S
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31
November
S M T W T F S
1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30
December
S M T W T F S
1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31
Press any key to continue . . .