MCS-284 (Fall, 2017) Project 1: Making a Calendar

Start: Friday 9/15; Due: Thursday 10/5, by the beginning of class


Overview

The de facto international standard civil calendar is the Gregorian calendar. Pope Gregory XIII introduced it in October 1582 to fix some problem that the Julian calendar was having. Every unix system has a command called cal for printing the Gregorian calendar. The cal program on Ubuntu can also print the Julian calendar when requested.

Your job is to write a simplified version of cal. Your version does not have to print the Julian calendar. It fact, your version should assume that the Gregorian calendar has been in use all along starting in year 1. Your version should perform as documented in this manual page.

Steps

First, you should get to know how the Ubuntu version of cal works. To do this, try issuing the following commands at your unix command line prompt and carefully note the outputs.

$ cal -m 11 2010
$ cal -m 13 2011
$ cal -m mar 2012
$ cal -m maRc 2013
$ cal -m MARCH 2014
$ cal -m MARCHY 2015
$ cal -m 5
$ cal 18
$ cal 2018
$ cal

Next, design your own cal algorithm so that it works as specified in the manual page. You should use the outputs from the issued commands above as a guide as to how your program should behave when the manual page does not give enough detail.

Last, translate your algorithm into a C program. Your program should be called cal.c. You should also modify the given manual page cal.txt to make it better. For example, your man page should describe all the valid ways to specify a month. It should also document any bugs the program has.

Leap Years

A leap year is a year that has 366 days instead of the usual 365 days. For the Gregorian calendar, each leap year has 29 days in February rather than the usual 28. It defines a leap year to be “a year divisible by 4 but not by 100, or divisible by 400.”

Deliverable

Submit your files cal.c and cal.txt via Moodle after you are finished. If you want to communicate anything to me then write in up in a (text file) called README and send it along with your submission.

If you are not clear as to what your program should produce (i.e., the project description did not provide enough clarification for you), you should talk to me during lectures and labs. I will also give details instructions on what your program should produce and how to approach the problem during lectures. So, it goes without saying that attendance is important.

Notes

  1. Just as important as the functionality of your code is your code’s readability to others. Therefore, in MCS-284 (and other computer science courses you will take), I will be paying close attention to your coding style and taking it into consideration when grading. For a description of what I am expecting, please consult the coding style guide available here.
  2. Britain and the British Empire adopted the Gregorian calendar in 1752. Your program must give correct output for all months and years since January 1753. It doesn’t matter what your program prints in response to inputs earlier than that (please consider this a hint).
  3. You can download San's cal program and try it out. The file is a linux ELF-64 binary executable. Once downloaded, make sure that the file has execute permission set. You can do this by typing

        chmod a+x ~/Downloads/cal

    before trying to run it. (I’m assuming you downloaded the file into your ~/Downloads directory.) Since it is a namesake of the system cal program, you have to use its full name to run. That is, you have to type something like

        ~/Downloads/cal feb 2020