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:
goto
statement is not allowed. The use of the continue
statement is not allowed. You may use the break
statement at the end of each case within a switch
statement,
but the use of break
is not allowed anywhere else.
In other words, your program should be well-structured (sections 3.4, 4.12). My solution to this program is 130 lines long, including all comments,
blank lines, and numerous printf
statements. The number of lines
in your program should be in the same vicinity. Use loops intelligently. If
you find yourself writing the same calculation over and over for each month of
the year, for example, you should ask yourself if that calculation should be
part of a loop. (Hint: every month of the year should be processed in an
identical way. In fact, the only differences between one month and another is
the name of the month and the number of days in the month. Your program should
consist of a main processing loop that runs 12 times, once for each month in
the year. Within the main processing loop, use a switch
statement (section 4.7) to display the name of the month
and to set the number of days in the month. Nothing else needs to be done
in your switch
statement.)
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)
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.)
Make sure both your C source code file and your README.txt file contain the name(s) and WPI username(s) of the author(s) of the files.
Submit your C source code file and your README.txt file to web-based turnin no later than 5pm on November 6. The name of the turnin project is Homework 2. Programs submitted after 5pm on November 6 will be tagged as late, and will be subject to the late homework policy.