Homework 2
Display a Calendar

Due: Tuesday, November 8 at 5pm

Outcomes

After successfully completing this assignment, you will be able to...

Before Starting

Re-read chapters 1 and 2 of Kernighan and Ritchie.

The Assignment

Write a C program called calendar.c that displays a one-year calendar. Prompt the user for the day of the week on which January 1 falls, and whether or not the year is a leap year. The day that January 1 falls on should be coded as: The calendar should be formatted as shown in the sample execution. Note that numbers are right-justified under the names of the days, and that two spaces separate the names of the days.

Include files

Assumptions and Restrictions

You may assume that the user enters valid data (your program does not have to check for valid responses). You should not use arrays in the solution for this program. You may define functions other than main() in your solution, but you are not required to do so.

Sample Execution

                        MONTHLY CALENDAR

This program displays a calendar.  You need to provide the day of the week
on which January 1 falls, and indicate whether or not the year is a leap year.

Enter the code number for the day of the week on which January 1 falls:
0- Sun    1- Mon    2- Tue    3- Wed    4- Thu    5- Fri    6- Sat

Enter day code now (0 - 6):  4

Is the calendar for a leap year? (type 1 for yes, 0 for no): 0



     ***    CALENDAR   ***

January

Sun  Mon  Tue  Wed  Thu  Fri  Sat
                      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

Sun  Mon  Tue  Wed  Thu  Fri  Sat
  1    2    3    4    5    6    7
  8    9   10   11   12   13   14
                 .
                 .
                 .
(output continues for all 12 months)

Deliverables

Write a short text file called README.txt that summarizes your program, how to run it, and detailing any assumptions and any problems you had. (You can use kwrite to create your README.txt file.) From your Linux account, submit your C source code file and your README.txt file using the following turnin command:

/cs/bin/turnin submit cs2301 PROJECT2 calendar.c README.txt

Programs submitted after 5pm on November 8 will be tagged as late, and will be subject to the late homework policy.

Grading

This assignment is worth 20 points. Your program must compile without errors in order to receive any credit. It is suggested that before you submit your program, compile it one more time on the CCC system to make sure that it compiles correctly.