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: 66% (3 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...
-
To assess the theories of bailment so as to be able to implement policies that limit potential legal liability. AppendixLO1
-
Graphing calculator sales. The table (next page) presents the quarterly sales index for one brand of graphing calculator at a campus bookstore. The quarters are based on an academic year, so the...
-
General Appliance (GA) builds coffeemakers and battery-powered small tools. For a long time, GA held areputation for strong, durable, and reliable appliances. This reputation began to decline,...
-
What is the rationale for the harmonization of international accounting standards?
-
Javier Andreas is in the process of developing a spreadsheet to budget annual sales and purchases of inventory for his company, The Backyard Place, a retail store that sells light ing, furniture, and...
-
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,...
-
For the given input for A and B, determine the output for Z. LET C = 3 * A + B IF ((C > 0) AND (B > 3)) THEN LET Z = C ELSE LET Z = 100 (a) A = 4, B = 5 (b) A = 10, B = 2 (c) A = -4, B = 5 (d) A =...
-
1. What does the phrase "cost of quality" mean? How might using this statement assist a company in addressing its quality issues? 2. What key distinctions exist between total quality human resource...
-
Does productivity in terms of output per labor our insure a company will be profitable? Why or why not? What questions should be asked to test whether productivity has increased? How do these answers...
-
How do the four Ps of marketing (product, price, promotion, place) differ in international markets?
-
Do you agree with the societal or political forces? Why or why not? Support your assertions with credible sources
-
How do the global transformational leadership models comprise a work environment that sees the need for change and embraces the new changes?Explain
-
A rigid container equipped with a stirring device contains 2.5 kg of motor oil. Determine the rate of specific energy increase when heat is transferred to the oil at a rate of 1 W, and 1.5 W of power...
-
A fast-food restaurant averages 150 customers per hour. The average processing time per customer is 90 seconds. a. Determine how many cash registers the restaurant should have if it wishes to...
-
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.
-
1,600 Balance Sheet The following is a list (in random order) of KIP International Products Company's December 31, 2019, balance sheet accounts: Additional Paid-In Capital on Preferred Stock $2,000...
-
Question 3 4 pts 9 x + 3 x 9 if x 0 Find a) lim f(x), b) lim, f(x), C), lim , f(x) if they exist. 3 Edit View Insert Format Tools Table : 12pt M Paragraph B IV A2 Tv
-
Mr. Geoffrey Guo had a variety of transactions during the 2019 year. Determine the total taxable capital gains included in Mr. Guo's division B income. The transactions included: 1. On January 1,...
Study smarter with the SolutionInn App