Implement a simple date class and solve the problem

Assignment Help Basic Computer Science
Reference no: EM131661793

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.

Reference no: EM131661793

Questions Cloud

Identify an area of practice where change theory : change theory that may impact real life situations or give rise to difficulties in the process of applying this theory
Changes in real gdp equilibrium : How can changes in real GDP equilibrium occur in the aggregate expenditures model and how do these changes relate to the multiplier? Give an example.
Significant ethical issues that ikea has faced recently : What are the most significant ethical issues that IKEA has faced recently? How has the company addressed them? IKEA is noted as Swedish giant retailer of home.
How will you be addressed by physicians and non-physicians : Describe why you have pursued the DNP degree and what changes in your professional stance will change as a result of obtaining the degree
Implement a simple date class and solve the problem : Implement a simple Date class. You should be able to represent any date from January 1, 1800, to December 31, 2500; subtract two dates.
County and municipal levels of government : Describe the relationship between the federal, state, county and municipal levels of government.
Calculate the equivalent units for direct materials : James Company uses process costing to track its costs in two sequential production departments: Calculate the equivalent units for direct materials
Why is it important to have both validity and reliability : What does the term reliability mean in testing and assessment?Why is it important to have both validity and reliability?
Disruptive technologies in business today : Discuss why and how a company uses disruptive technologies in its business today

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Identifies the cost of computer

identifies the cost of computer components to configure a computer system (including all peripheral devices where needed) for use in one of the following four situations:

  Input devices

Compare how the gestures data is generated and represented for interpretation in each of the following input devices. In your comparison, consider the data formats (radio waves, electrical signal, sound, etc.), device drivers, operating systems suppo..

  Cores on computer systems

Assignment : Cores on Computer Systems:  Differentiate between multiprocessor systems and many-core systems in terms of power efficiency, cost benefit analysis, instructions processing efficiency, and packaging form factors.

  Prepare an annual budget in an excel spreadsheet

Prepare working solutions in Excel that will manage the annual budget

  Write a research paper in relation to a software design

Research paper in relation to a Software Design related topic

  Describe the forest, domain, ou, and trust configuration

Describe the forest, domain, OU, and trust configuration for Bluesky. Include a chart or diagram of the current configuration. Currently Bluesky has a single domain and default OU structure.

  Construct a truth table for the boolean expression

Construct a truth table for the Boolean expressions ABC + A'B'C' ABC + AB'C' + A'B'C' A(BC' + B'C)

  Evaluate the cost of materials

Evaluate the cost of materials

  The marie simulator

Depending on how comfortable you are with using the MARIE simulator after reading

  What is the main advantage of using master pages

What is the main advantage of using master pages. Explain the purpose and advantage of using styles.

  Describe the three fundamental models of distributed systems

Explain the two approaches to packet delivery by the network layer in Distributed Systems. Describe the three fundamental models of Distributed Systems

  Distinguish between caching and buffering

Distinguish between caching and buffering The failure model defines the ways in which failure may occur in order to provide an understanding of the effects of failure. Give one type of failure with a brief description of the failure

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd