Using the Day class of Worked Example 2.1, write a Day Tester program that constructs a Day
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, and then computes the difference between that day and today. Print the difference and the expected value.
Data from worked example 2.1.
Transcribed Image Text:
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.
Fantastic news! We've Found the answer you've been seeking!
Step by Step Answer:
Answer rating: 50% (2 reviews)
Answered By
Nazrin Ziad
I am a post graduate in Zoology with specialization in Entomology.I also have a Bachelor degree in Education.I posess more than 10 years of teaching as well as tutoring experience.I have done a project on histopathological analysis on alcohol treated liver of Albino Mice.
I can deal with every field under Biology from basic to advanced level.I can also guide you for your project works related to biological subjects other than tutoring.You can also seek my help for cracking competitive exams with biology as one of the subjects.
3.30+
2+ Reviews
10+ Question Solved
Related Book For
Question Posted:
Students also viewed these Java Programming questions
-
can someone solve this Modern workstations typically have memory systems that incorporate two or three levels of caching. Explain why they are designed like this. [4 marks] In order to investigate...
-
Using the Day class of Worked Example 2.1, write a program that generates a Day object representing February 28 of this year, and three more such objects that represent February 28 of the next three...
-
answer the question clearly You are building a flight-control system for which a convincing safety case must be made. Would you assign the tasks of safety requirements engineering, test case...
-
Which statement about the pass-by-reference is NOT true? a.Every time you pass a reference variable to a method, you also pass the object referred by the refenerece variable to the method. b.In the...
-
A steam power plant operates on the simple ideal Rankine cycle between the pressure limits of 10 kPa and 10 MPa, with a turbine inlet temperature of 600C. The rate of heat transfer in the boiler is...
-
Evaluate the definite integrals in Problem. 3 3 dy
-
How does make determine whether a target needs to be rebuilt?
-
Change in PrincipleInventory Methods Whitman Company began operations on January 1, 2008, and uses the average cost method of pricing inventory. Management is contemplating a change in inventory...
-
Simplify the given expression and write the answer with only positive exponents. -113 P 3/7 7 3 54x y z 2 w) 3) (w + 2) (3w + w 4 2 (-3x +7x+8)= (x * + 7x *-12x-1) - 5 27-7-28 20-x-22 712-24-8...
-
In a pest-eradication program, sterilized male flies are released into the general population each day. Ninety percent of those flies will survive a given day. How many flies should be released each...
-
Using the Picture class of Worked Example 2.2, write a Half Size Picture program that loads a picture and shows it at half the original size, centered in the window. Data from worked example 2.2....
-
Look at the API of the Point class and find out how to construct a Point object. In a PointTester program, construct two points with coordinates (3, 4) and (3, 4). Find the distance between them,...
-
Find the steady-state current I (t) in the RLC-circuit in Fig. 275, where R = 10 , L = 1 H, C = 10 -1 F and with E(t) V as follows and periodic with period 2. Graph or sketch the first four partial...
-
In what ways artificial intelligence threatens our conventional way of learning?
-
Choose a marketing/ business you'd like to solve ? How would Isolve the issue of online vs in person retail shopping? how do I entice shoppers to in person retail shopping with the convenience of...
-
Rewrite this: The cost of product warranties (or product guarantees) cannot be predicted with certainty. However, to match expenses and revenues, we estimate the cost. The estimated warranty...
-
Question 1 Answer saved Points out of 1.00 Not flaggedFlag question Question text __________ is a global standard and IT management framework created to help businesses develop, organize, and...
-
Provide an analysis of the market relevant to the business like market trends and growth rate.
-
1. Is this ruling fair? 2. Should American Express have realized there was a problem when it received checks payable to Amerex? Similarly, should the Metropolitan Opera Company have wondered why it...
-
Find the intercepts and then graph the line. (a) 2x - 3y = 6 (b) 10 - 5x = 2y
-
What type of topology is used when customers in an area use DSL modems for data transfer purposes? Explain.
-
What is the relationship between STS and STM?
-
What type of topology is used when customers in an area use cable modems for data transfer purposes? Explain.
-
You are cotton farmer. Trace the supply chain from farming cotton to the end result of a Tee- shirt sold on the Boardwalk at the shore. What problems would you encounter in every step of the supply...
-
How Digital Strategy and Transformation in what way and why is digital disrupting your industry currently? , evaluate how digital is changing the industry, business, and market environment of your...
-
1. How can YOU be exceptional when applying for a job? 2. What is the secret in a "Purple Cow" job-seeking technique? Explain. Do you know any of your classmates who are like this? Explain. 3. When...
Study smarter with the SolutionInn App