Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Design a class called Date. The class should store a date in three integers: month, day, and year. There should be member functions to print

Design a class called Date.

The class should store a date in three integers: month, day, and year. There should be member functions to print the data in the following forms:

12/25/2017

December 25, 2017

25 December 2017

Demonstrate the class by writing a complete program implementing it.

Input Validation: Do not accept values for the day greater than 31 or less than 1 for month: January, March, May, July, August, October, December. Do not accept values for the day greater than 30 or less than 1 for month: April, June, September, November. Do not accept values for the days greater than 29 for February if it is a leap year. Do not accept values for the days greater than 28 if it is not a leap year. Do not accept values for the month greater than 12 or less than 1.

In general, terms the algorithm for calculating a leap year is as follows...

A year will be a leap year if it is divisible by 4 but not by 100. If a year is divisible by 4 and by 100, it is not a leap year unless it is also divisible by 400.

Thus, years such as 1996, 1992, 1988 and so on are leap years because they are divisible by 4 but not by 100. For century years, the 400 rule is important. Thus, century years 1900, 1800 and 1700 while all still divisible by 4 are also exactly divisible by 100. As they are not further divisible by 400, they are not leap years.

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

Microsoft SQL Server 2012 Unleashed

Authors: Ray Rankins, Paul Bertucci

1st Edition

0133408507, 9780133408508

More Books

Students also viewed these Databases questions