In this assignment, you will try to write a calendar program using what you learned in assignments 4 and 5. Copy this program to your PC. The program compiles and runs OK but does not produce valid output. You have to follow the steps below to gradually develop it into a calendar program.
6.1. Write a function leapyear that decides if a given year is a leap year. Also, convert assignment 4.4 into a function month1. It takes in a month and a year, then returns the weekday of that month (0 for Sunday, 1 for Monday, etc.)
another function called printweek. The purpose of printweek is to produce one row of output
to represent a week in a calendar. It takes in four parameters lskip, first, last, and rskip. It first skips lskip days, prints out first, first+1, …, last, and then
skips rskips days. For example,
printweek(0, 1, 7, 0) prints
1 2 3 4 5 6 7
printweek(3, 1, 4, 0) prints
1 2 3 4
printweek(0, 26, 31, 1) prints
26 27 28 29 30 31
If your function works correctly, you will see a calendar for December 2004 printed out on the screen.
6.3. Now that you have these functions working, you can start writing the real single-month calendar program. Your program should take in any valid month and year and then print out the calendar for the given month correctly.
6.4. Why stop with a single-month calendar? Modify your program so that it reads in a valid year and produces a single-column yearly calendar.
Extra point problem:
6.5. Further modify 6.4 to create a 3-column yearly calendar similar to the samples given in assignment 4.
Sample executable programs will be posted shortly. Turn in your assignment (a single file) to http://188.8.131.52. The deadline is midnight, Dec. 9, 2004. Extra points will be given for early birds, so try your best to submit your program as soon as possible.
Once again, don’t cheat.