Question: Using the Day class of Worked Example 2.1, write a Day Tester program that constructs a Day object representing today, adds ten days to it,
Using the Day class of Worked Example 2.1, write a Day Tester program that constructs a Day object representing today, adds ten days to it, and then computes the difference between that day and today. Print the difference and the expected value.
Data from worked example 2.1.





WORKED EXAMPLE 2.1 How Many Days Have You Been Alive? Many programs need to process dates such as "February 15, 2010". The worked_example_1 directory of this chapter's companion code contains a Day class that was designed to work with calendar days. The Day class knows about the intricacies of our calen- dar, such as the fact that January has 31 days and February has 28 or sometimes 29. The Julian calendar, instituted by Julius Caesar in the first century bce, introduced the rule that every fourth year is a leap year. In 1582, Pope Gregory XIII ordered the implementation of the calen- dar that is in common use throughout the world today, called the Gregorian calendar. It refines the leap year rule by specifying that years divisible by 100 are not leap years, unless they are divisible by 400. Thus, the year 1900 was not a leap year but the year 2000 was. All of these details are handled by the internals of the Day class. The Day class lets you answer questions such as How many days are there between now and the end of the year? What day is 100 days from now? Problem Statement Your task is to write a program that determines how many days you have been alive. You should not look inside the internal implementation of the Day class. Use the API documentation by pointing your browser to the file index.html in the worked example_1/api subdirectory.
Step by Step Solution
3.41 Rating (157 Votes )
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
