Reimplement the Day class of Worked Example 2.1 to be mutable. Change the methods addDays, nextDay, and
Question:
Reimplement the Day class of Worked Example 2.1 to be mutable. Change the methods addDays, nextDay, and previousDay to mutate the implicit parameter and to return void. Also change the demonstration program.
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? MAN 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: 100% (1 review)
Answered By
Mugdha Sisodiya
My self Mugdha Sisodiya from Chhattisgarh India. I have completed my Bachelors degree in 2015 and My Master in Commerce degree in 2016. I am having expertise in Management, Cost and Finance Accounts. Further I have completed my Chartered Accountant and working as a Professional.
Since 2012 I am providing home tutions.
3.30+
2+ Reviews
10+ Question Solved
Related Book For
Question Posted:
Students also viewed these Java Programming questions
-
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...
-
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...
-
re Regular Languages and Finite Automata (a) Let L be the set of all strings over the alphabet {a, b} that end in a and do not contain the substring bb. Describe a deterministic finite automaton...
-
What is the timestep value ? And how do I go about altering from downstream to upstream? The following code solves the advection equation 1 2 3 4 5 6 7 8 9- 10 - 11 12 - 13 - 14 - 15 - 16 - 17 18 19...
-
Repeat Problem 9161 assuming isentropic efficiencies of 85 percent for both the turbine and the compressor.
-
Match each transaction or event to one of the following activities of an organization: financing activities (F), investing activities (I), or operating activities (0). a. b. C. d. e. An owner...
-
A company growing at an annual rate of 35 percent will double in size in just two years. A company growing at an 18 percent rate will double in size in four years. A company growing by 12 percent...
-
A flat (unbanked) curve on a highway has a radius of 220.0 m. A car rounds the curve ata speed of 25.0 m/s. (a) What is the minimum coefficient of friction that will prevent sliding? (b) Suppose the...
-
As a result of a slowdown in operations, Tradewind Stores is offering employees who have been terminated a severance package of $95,000 cash paid today; $95,000 to be paid in one year, and an annulty...
-
Problem Statement: The aim of this case study is to propose a daily capacity level and level of resourcing required for Q2 & Q3 2023. The proposed daily capacity level should achieve the highest...
-
Write static methods: that compute the volume and surface area of a cube with height h, sphere with radius r, a cylinder with circular base with radius r and height h, and a cone with circular base...
-
Reimplement the BankAccount class so that it is immutable. The deposit and withdraw methods need to return new BankAccount objects with the appropriate balance.
-
An investor buys a call on ABC stock with a strike price of K and writes a put with the same strike price and maturity. Assuming the options are European and that there are no dividends expected...
-
Part 2 One Stop Electrical Shop are merchandisers of household fixtures & fittings. The business began the last quarter of 2020 (October to December) with 25 Starburst Wall Clocks at a total cost of...
-
A species of butterfly has three subspecies A, B, and C. A scientist is trying to classify observed. specimens into these subspecies based on the color of their wings, which can be blue, green, pink,...
-
Stock during the year were sold for $8 per share. On December 31 , Portland had no remaining treasury stock. Required: Prepare the necessary journal entries to record any transactions associated with...
-
2) 20 pts. A 2-kg block rests on a wedge that has a coefficient of friction between the wedge and block of 0.3. The system accelerated to the right. Determine the maximum acceleration of the system...
-
ABC Ltd. is concerning about its poor performance and considering whether or not dropping the production and sells of product R, which incurs losses of Birr 4000. Additional information: The salaries...
-
Complete this table for H2O v, m3/kg 7.72 P. kPa T,C 50 250 Phase description 400 500 350 Saturated vapor 110
-
If the joint cost function for two products is C(x, y) = xy2 + 1 dollars (a) Find the marginal cost (function) with respect to x. (b) Find the marginal cost with respect to y.
-
In SCTP, the value of the cumulative TSN in a SACK is 23. The value of the previous cumulative TSN in the SACK was 29. What is the problem?
-
In Figure 25.10 in the text, how does the server know that a client has requested a service? Figure 25.10 Sockets used in TCP communication Server O Connection establishment Client 1 Data transfer...
-
Write a program to make the UDP server program in Table 25.1 more generic: to receive a request, to process the request, and to send back the response. Table 25.1 Table 25.1 Echo server program using...
-
Nitin is paid a base salary of $200 per week and commission at the rate of 3% for sales over $5000, 4% if his sales are over $8000, and 5% if sales are over $15,000. How much will Nitin earn in a...
-
Safa is paid a base salary of $1500 per month and a commission of 6% on all sales over $75,000. Last month, Safa's gross salary was $4440. What were her sales for the month? a$149,000 b$124,000...
-
Your regular hourly rate of pay is $15.86, and you are paid double time for all work on weekends and for any time over forty hours per week (Monday to Friday). Calculate your gross earnings for a...
Study smarter with the SolutionInn App