Question: Write a C++ program that will prompt the user to enter a year and produce a calendar for that year. Do not forget that years
Write a C++ program that will prompt the user to enter a year and produce a calendar for that year. Do not forget that years that are divisible by 4 but not divisible by 100 unless they are divisible by 400 are leap years.
The first day of the year can be calculated using the following formula:
W = ((29 - 2*C + y + y/4 + C/4)%7 + 7) % 7
where
-
Y is the year
-
C = (Y-1) / 100, the century
-
y = (Y-1) % 100
-
/ denotes the integer division
-
% denotes the integer remainder (mod)
-
W is the week day (0=Sunday, ..., 6=Saturday)
An example is given below:
| Enter year: 2019 2019 January SMTWTFS ---------------------------------- 12345 6 7 8 9101112 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 February SMTWTFS ---------------------------------- |
| 12 3456789 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 March S M T W T F S ---------------------------------- 12 3456789 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
Note that Sundays should be displayed in red color. For displaying different colors in your output you can use the header file colors.h that you can find on your intranet. Feel free to practice with different colors for this assignment.
Assessment Criteria
The marks (maximum 100) for this coursework assignment will be based on the following assessment criteria:
-
Working version of the program 70%
-
Identifiers, comments and style 30%
Note: You are ONLY allowed to include the libraries: iostream, iomanip, and windows.h.
January S M T W T F s OL On 1 8 15 22 29 6 13 20 27 4 11 18 2 9 16 23 30 7 14 21 28 Ann 3 10 17 24 31 00 5 12 19 26 HN 25 February S M T W T F s 7 14 3 10 17 24 H. 4 11 18 25 6 13 20 5 12 19 26 2 9 16 23 Nom 15 22 N P 21 28 27 March S M W T F s 2 9 4. o w 1 8 15 11 - 3 10 17 24 31 5 12 19 26 6 13 20 27 7 14 21 16 23 18 a 22 29 N 25 28 30
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
