Due: Tuesday, Feb 23rd by 11:59 PM
Update Feb 16th: Correction to the Julian Day Number formula.
Start by downloading CS101_Assign3.zip, saving it in the directory H:\CS101.
Start a Cygwin Bash Shell and run the following commands:
cd h: cd CS101 unzip CS101_Assign3.zip cd CS101_Assign3
Using Notepad++, open the file
You will add your code to this file.
Run the command
when you are ready to compile the program. To run the program, run the command
Your task is to write a program which prompts the user to enter a day, month, and year, and then prints a calendar of that month, highlighting the day the user entered.
For example, let's say that the user entered the date 2 8 2008, meaning February 8th, 2008:
The program should display the following calendar:
The calendar displayed should have the name of the month and the year at the top, then a row of column headers with the days of the week (abbreviations are fine), and then a table showing where each day in the month falls.
The day entered by the user should be highlighted by drawing a colored box around it.
Your program should support any date in the Gregorian (modern) calendar.
A Julian Day Number is an integer representation of dates since January 1, 4713 BC.
Assuming that M is a month (1 for January), D is a day of the month (1 for the first day of the month), and Y is a year, then the Julian Day Number (JDN) can be computed as follows:
JDN = (1461 × (Y + 4800 + (M − 14)/12))/4 +(367 × (M − 2 − 12 × ((M − 14)/12)))/12 − (3 × ((Y + 4900 + (M - 14)/12)/100))/4 + D − 32075
Note that all divisions in the formula above are integer divisions, meaning that any fraction in the quotient is discarded.
Any Julian Day Number can be taken modulo 7 in order to determine which day of the week the day falls on:
JDN % 7 == 0 Monday JDN % 7 == 1 Tuesday JDN % 7 == 2 Wednesday JDN % 7 == 3 Thursday JDN % 7 == 4 Friday JDN % 7 == 5 Saturday JDN % 7 == 6 Sunday
The program can determine how to display a calendar for the month containing the user's date using the following approach:
To determine the number of days in the month:
A leap year is any year which either
Important: You will use printf and scanf to prompt the user to enter the day, month, and year. Make sure that the calls to these functions take place before the calls to the display functions (e.g., cons_clear_screen).
Use the display functions (e.g., cons_move_cursor, cons_change_color, etc.) that you used in Lab 8 in order to precisely control the appearance of the calendar.
Your grade will be determined as follows:
An insane extra credit option is available for up to 10 additional points.
Points may be deducted for poor coding style. You should make sure you use meaningful variable names, write comments to document what your code is doing, and properly indent all code in nested blocks (if/else statements and loops.)
To submit your work, make sure your Calendar.cpp file is saved, and type the command
Enter your Marmoset username and password (which you should have received by email.) Note that your password will not be echoed to the screen. Make sure that after you enter your username and password, you see a message indicating that the submission was successful.
Important: Make sure that you check the file(s) you submitted to ensure that they are correct. Log into the server using the following URL:
You should see a list of labs and assignments. In the row for assign3, click the link labeled view. You will see a list of your submissions. Download the most recent one (which should be listed first). Verify that it contains the correct files.
You are responsible for making sure that your submission contains the correct file(s).