Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ Not JAVA Write a program that, given a month and year, prints a calendar, such as June 2016 Su Mo Tu We Th Fr

C++ Not JAVA

image text in transcribed

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

 June 2016
Su Mo Tu We Th Fr Sa
 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

To find out the weekday of the first day of the month, call this function:

/**
 Computes the weekday of a given date.
 @param year the year
 @param month the month (1 = January ... 12 = December)
 @param day the day of the month
 @return the weekday (0 = Sunday ... 6 = Saturday)
*/
int day_of_week(int year, int month, int day)
{
 int y = year;
 int m = month - 1;
 if (month  
 return (y + y / 4 - y / 100 + y / 400
 + 3 * m + 4 - (m - m / 8) / 2 + day) % 7;
}

Make a helper function to print the header and a helper function to print each row.

Write a program that, given a month and year, prints a calendar, such as June 2016 Su Mo Tu We Th Fr Sa 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 To find out the weekday of the first day of the month, call this function: k* Computes the weekday of a given date. @param year the year @param month the month (1-January. 12 December) @param day the day of the month @return the weekday (0 - Sunday 6 - Saturday) int day of week(int year, int month, int day) int y-year; int m month - 1; if (month

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Hands On Database

Authors: Steve Conger

1st Edition

013610827X, 978-0136108276

More Books

Students also viewed these Databases questions

Question

What does Processing of an OLAP Cube accomplish?

Answered: 1 week ago