Post-Lab - Lab (4) - A Calendar



Write a C++ program that prints a calendar for a given year.  Call this program calendar.cpp. You can use the program ex44.cpp as the starting point. The program prompts the user for three inputs:

      1) The year for which you are generating the calendar.
      2) The day of the week that January first is on, you will use the following notation to set the day of the week:

      0  Sunday                     1  Monday                   2  Tuesday                   3 Wednesday
      4  Thursday                 5  Friday                      6  Saturday

Your program should generate a calendar similar to the one shown in the example output below. The calendar should be printed on the screen. Your program should be able to handle leap years. A leap year is a year in which we have 366 days. That extra day comes at the end of February. Thus, a leap year has 366 days with 29 days in February. A century year is a leap year if it is divisible by 400. Other years divisible by 4 but not by 100 are also leap years.

Example: Year 2000 is a leap year because it is divisble by 400.  Year 2004 is a leap year because it is divisible by 4 but not by 100.

You can use as many functions as you wish. Your program should clearly describe the functionality of each function and should display the instructions on how to run the program.

Sample Input:

Enter the year for which you wish to generate the calendar: 2004
Enter the day of the week that January first is on:  4

Sample output:

Calendar for year 2004

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
…        ..          ..          ..          ..          ..          ..
..          ..
..
..
 

Instructions to return your lab to the teacher: (5 points penalty if instructions are not followed appropriately)

  1. Be sure you return all the printed files where you have written all your answers.
  2. Transfer ONLY the source files you have written from loki to your local Windows machine and collect them in a  folder called YourLastNameLab4 (ex. AGuercioLab4). Be sure you did not copy any executable file in this folder. If you did, please remove it from the folder.
    The files to be zipped are:
    Exercise Pre Lab: 
    WarmUp.txt
    Exercise 4-2:
    ex42.cpp
    ex43.cpp
    Exercise 4-3:
    ex44.cpp
    Post Lab:
    calendar.cpp
  3. Now exit from the folder, right click on the folder and choose WinZip-->Zip and e-mail. This action will pack your folder and attach it to an e-mail. You can use a Rar Program if you have that program instead of the Zip program.
  4. Send the e-mail to kschaffe@kent.edu with the subject CS23021 Lab 4 Submission.
  5. Send your e-mail before the deadline to receive full credit.
  6. ATTENTION: Return a printed copy of the source files to your instructor as well.

Congratulations! You have completed another Lab of CS I !! :-))