Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

Question: Implement a simple Date class. You should be able to represent any date from January 1, 1800, to December 31, 2500; subtract two dates; increment a date by a number of days; and compare two dates using both equals and compareTo. A Date is represented internally as the number of days since some starting time, which, here, is the start of 1800. This makes all methods except for construction and toString trivial. The rule for leap years is a year is a leap year if it is divisible by 4 and not divisible by 100 unless it is also divisible by 400. Thus 1800, 1900, and 2100 are not leap years, but 2000 is. The constructor must check the validity of the date, as must toString. The Date could be bad if an increment or subtraction operator caused it to go out of range. Once you have decided on the specifications, you can do an implementation. The difficult part is converting between the internal and external representations of a date. What follows is a possible algorithm. Set up two arrays that are static fields. The first array, daysTillFirstOfMonth, will contain the number of days until the first of each month in a nonleap year. Thus it contains 0, 31, 59, 90, and so on. The second array, daysTillJan1, will contain the number of days until the first of each year, starting with firstYear. Thus it contains 0, 365, 730, 1095, 1460, 1826, and so on because 1800 is not a leap year, but 1804 is. You should have your program initialize this array once using a static initializer. You can then use the array to convert from the internal representation to the external representation.

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M92470495
  • Price:- $15

Priced at Now at $15, Verified Solution

Have any Question?


Related Questions in Computer Engineering

In my sample database i need to use select statements to

In my sample database I need to use SELECT statements to find the following: 1) Find the full names of supervisors together with the total number of employees directly supervised by each one of them. 2) Find the full nam ...

Suppose a coworker approaches you and asks what an ethical

Suppose a coworker approaches you and asks what an ethical hacker does. She does not understand the role that an ethical hacker plays in the security industry and assumes that such a hacker intentionally causes damage. E ...

The strfirstname and strlastname variables contain the

The strFirstName and strLastName variables contain the strings "Jane" and "Jones", respectively. Which of the following statements will display a string as "Jones, Jane" (the last name, a comma, a space, and the first na ...

Question whether in a scholarly or practitioner setting

Question: Whether in a scholarly or practitioner setting, good research and data analysis should have the benefit of peer feedback. For this Discussion, you will post your response to the hypothesis test, along with the ...

Consider the following production function that is already

Consider the following production function that is already written in per worker terms: y = Akαh 1-α where h represents human capital per worker. Suppose we are given the following information: capital per worker in an e ...

A sample of 1000 us households is taken and the average

A sample of 1,000 U.S. households is taken and the average amount of newspaper garbage or recycling is found to be 27.8 pounds with a standard deviation of 2 pounds. Estimate, with 90% confidence, the mean amount of news ...

Question what is stuxnet and what are its real-world

Question : What is Stuxnet and what are its real-world implications? Should your national government be concerned about the potential of a Stuxnet-like attack? Why or why not.

Systems analysis project personal trainer inc owns and

Systems analysis project Personal Trainer, Inc. owns and operates fitness centers in a dozen Midwestern cities. The centers have done well, and the company is planning an international expansion by opening a new "superce ...

Whats the relationship between organizational performance

What's the relationship between organizational performance and financial management practices. These include capital structure decision, investment appraisal techniques, dividend policy, working capital management and fi ...

Like users computers in a domain will have an account

Like users, computers in a domain will have an account established for them. Their account can be seen in AD Users and Computers and viewed or modified there. What if you were going to add a new group of people in a new ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As