Write a program that, given a month and year, prints a calendar, such as June 2016 Su Mo Tu We Th Fr Sa XXXXXXXXXX XXXXXXXXXX XXXXXXXXXX XXXXXXXXXX XXXXXXXXXX You should create at least two functions:...

Write a program that, given a month and year, prints a calendar, such as

June 2016

Su Mo Tu We Th Fr Sa

XXXXXXXXXX

XXXXXXXXXX

XXXXXXXXXX

XXXXXXXXXX

XXXXXXXXXX


You should create at least two functions:


1) int JulianDayDate(int month, int day, int year)

This function should return the day of the week, given a date. Here is one algorithm to do this given a Julian date:


JMD = (day XXXXXXXXXX * (month + 12 * XXXXXXXXXXmonth) / XXXXXXXXXX) / 5) +

(365 * (year XXXXXXXXXXmonth) / 12))) +

((year XXXXXXXXXXmonth) / 12)) / 4) -

((year XXXXXXXXXXmonth) / 12)) / 100) +

((year XXXXXXXXXXmonth) / 12)) / XXXXXXXXXX) % 7;

This formula returns an index of the day of the week. // 0 = Monday, 1 = Tuesday, ..., 6 = Sunday

You can use the above to find out the weekday of the first day of the month for your calendar.


2) Next, you should create your own function to return the number of days in the month that you need to print. Your function should correctly handle leap years. Make sure your test output shows the various possible outputs, month lengths of 28,29,30,31.


int getDaysInMonth(int month, int year)

Hints:


Use helper methods to print the header and to print each row will make your code easier to understand and debug.


Each row except the header will have 20 characters.


You may want to also create a method that calculates the number of leading spaces before the first date of the month to make your code more modular.


Submission Instructions:



Submit C++ source code files that solve the defined problem.



Submit a screenshot of your test output including all test cases. You should validate your date inputs.



May 18, 2022
SOLUTION.PDF

Get Answer To This Question

Submit New Assignment

Copy and Paste Your Assignment Here