CMSC 201 Dates Out: Wednesday 9/24/03 |
The objective of this assignment is to get you started writing programs in C in the UNIX environment. Its main emphasis is design, so we will be designing the project together in class. This project will also give you practice writing functions, loops, switch statements and using separate compilation.
You are just beginning to learn to program in C and you want to challenge yourself by writing a large enough program to test your design skills and to give you practice with separate compilation. You decide to write a program that you can release as public domain software (give away to others). It should be something that is a little bit useful and maybe even a little bit fun ... something to do with dates.
First let's think about the useful part. It would be useful to be able to find the Julian date of any date the user enters. The Julian date is what day of the year it is. e.g. 01/01 corresponds to the julian date 1, 01/25 corresponds to the julian date 25, and 02/01 corresponds to the julian date 32.
Now the fun part ... It would be fun (and maybe even useful) for the user to be able to enter the current date and someone's birthdate and let the program respond with their age. e.g. I was born 9/29/1949, so today 9/25/2003, I am 53 years old. Beginning on Monday, 9/29/2003, I will be 54, until this time next year ... but you know how ages work.
And now the totally useless, but fun part ... It would be fun for the program to tell what a person's astrological sign is, given the person's birthdate. Here is a chart of dates and signs:
Astrological Sign | Beginning Date | Ending date |
---|---|---|
Aries | Mar 21 | Apr 19 |
Taurus | Apr 20 | May 20 |
Gemini | May 21 | June 21 |
Cancer | June 22 | July 22 |
Leo | July 23 | Aug 22 |
Virgo | Aug 23 | Sept 22 |
Libra | Sept 23 | Oct 23 |
Scorpio | Oct 24 | Nov 21 |
Sagittarius | Nov 22 | Dec 21 |
Capricorn | Dec 22 | Jan 19 |
Aquarius | Jan 20 | Feb 18 |
Pisces | Feb 19 | Mar 20 |
Design (to be done in class) and code a project that after printing a greeting to the user, presents the user with a menu and allows him to choose to find a julian date, find someone's age or find someone's sign given their birthday. After displaying the results, the user should be presented with the menu again, so that s/he can continue to make choices.
Since you are distributing this software to others, you must use separate compilation and provide the interface for the user. This is in the form of a well commented header (.h) file. You must have 3 files. The file that contains main() MUST be called proj1.c; the file containing the function definitions MUST be called dates.c and the header file MUST be called dates.h
You are required to use a switch statement to handle the menu requests. There are also other places where the switch statement is the appropriate choice too.
You must adhere to the design given in class. The function prototypes given below must be used and may NOT be altered in anyway.
You must handle leap years properly and according to the following rule:
Although your output need not be identical to the above, all information (including the greeting) must be present.
Please be aware that this is definitely NOT a complete test of the program. Your testing should be much more extensive.
You are to use separate compilation for this project, so you will be
submitting three files.
Your C source code file that contains main() MUST be called
proj1.c. The file which contains the function definitions
MUST be called dates.c and the header file MUST be
called dates.h
To submit your project, type the following at the Unix prompt. Note that the project name starts with uppercase 'P'.
submit cs201 Proj1 proj1.c dates.c dates.h
To verify that your project was submitted, you can execute the following command at the Unix prompt. It will show all files that you submitted in a format similar to the Unix 'ls' command.
submitls cs201 Proj1