Write a class to represent a date. A date has a month, day, and year. Your...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Write a class to represent a date. A date has a month, day, and year. Your date class should support the following operations: 1. Create a date object. Write a constructor that takes initial values for day, month, and year 2. Create a date object from an existing date object. A copy constructor. 3. toString() return a String representation of the date in the American format (i.e., January 1, 2018) - 4. Add one day to the date 5. Subtract one day from the date 6. [Optional]. Add d days to the date where d is a parameter to the method 7. Add one month to the date 8. Subtract one month from the date 9. Return the number of days past January 1. 10. Implement a compareTo method that tells you whether another date is before you, the same as you, or comes after you. Remember that compareTo returns a negative value, zero, or positive value. Write a Date class and a tester that enables you to test the class by testing the methods as many times as you want in any order with different data. You can ignore leap year. Your tester should display a menu of choices in a loop. Upload your UML diagram, all of your java files, and a snip of the output to show that it works. Hint: Create an array that has the number of days in each month. Write a class to represent a date. A date has a month, day, and year. Your date class should support the following operations: 1. Create a date object. Write a constructor that takes initial values for day, month, and year 2. Create a date object from an existing date object. A copy constructor. 3. toString() return a String representation of the date in the American format (i.e., January 1, 2018) - 4. Add one day to the date 5. Subtract one day from the date 6. [Optional]. Add d days to the date where d is a parameter to the method 7. Add one month to the date 8. Subtract one month from the date 9. Return the number of days past January 1. 10. Implement a compareTo method that tells you whether another date is before you, the same as you, or comes after you. Remember that compareTo returns a negative value, zero, or positive value. Write a Date class and a tester that enables you to test the class by testing the methods as many times as you want in any order with different data. You can ignore leap year. Your tester should display a menu of choices in a loop. Upload your UML diagram, all of your java files, and a snip of the output to show that it works. Hint: Create an array that has the number of days in each month.
Expert Answer:
Related Book For
Java How To Program Late Objects Version
ISBN: 9780136123712
8th Edition
Authors: Paul Deitel, Deitel & Associates
Posted Date:
Students also viewed these programming questions
-
12) Overtha Hill is ready to retire and has a choice of three pension plans. Plan A provides for an immediate cash payment of $213,000. Plan B provides for the payment of $30,000 per year for 10...
-
CANMNMM January of this year. (a) Each item will be held in a record. Describe all the data structures that must refer to these records to implement the required functionality. Describe all the...
-
Predictive text entry systems are familiar on touch screens and mobile phones. This question asks you to consider how the same principles might be used in a programming editor for creating Java code....
-
Suppose the final exam in this class has a normal, or bell-shaped, grade distribution of exam scores, with an average score of 80. An approximate function that models your classs grades on the exam...
-
How is one likely to change ones lifestyle at different stages of ones household life cycle? Over ones life, is one likely to assume more than one of the VALS lifestyle profiles described?
-
The Blair Companys three assembly plants are located in California, Georgia, and New Jersey. Previously, the company purchased a major subassembly, which becomes part of the final product, from an...
-
\(S_{1}\) and \(S_{4}\) are spanning trees but \(S_{2}\) and \(S_{3}\) are not. Use the figure shown. Draw a graph that fits the given description. a b a a b a b C 51 d 5 d C d 53 54
-
Lowell Company makes and sells artistic frames for pictures. The controller is responsible for preparing the master budget and has accumulated the following information for 2017. Lowell has a labor...
-
Select from the drop-down menus to identify the secant line and the tangent line at x = 2 for the graph of the function shown. Line \"a" is the line, and line \"b\" is the line at x = 2. For the...
-
Chestnut, Incorporated reported the following balances on its balance sheet at December 31, Year 1: Total Assets Total Liabilities Common Stock Retained Earnings Total Equity Total Liabilities and...
-
How much channel power does IKEA possess? What are the implications for the role it plays in the channel?
-
Costco Costco is one of the largest retail sales companies in the United States, and it has more than 500 stores in 37 states and eight countries. Despite low profit margins in the retailing...
-
Campbell Limited is a manufacturer of telecommunication switches. The company uses job order costing to assign costs to its product. During 2019, Campbell manufactured a Switch for Eastlink...
-
How modern managerial accounting practices help companies grow Companies can find new ways to grow through forward-looking managerial accounting approaches. Improving business performance and...
-
A consol bond pays forever two semiannual coupons at an annual coupon rate of 3.60% In other words, the initial principal is never reduced nor repaid.The yield-to-maturity is 6.80% and a coupon was...
-
41. Gogalor Co. se incorpor el 1 de enero de2020. Tras la inspeccin de su libro de acciones y transferencias,se observaron las siguientes transacciones que afectaron susacciones1 de enero No. 1 answer
-
The water in tank A is at 270 F with quality of 10% and mass 1 lbm. It is connected to a piston/cylinder holding constant pressure of 40 psia initially with 1 lbm water at 700 F. The valve is opened,...
-
Explain the measurement and reporting of intangible assets. - Intangible assets are recorded at cost, which is any expenditure necessary to acquire the asset and prepare it for use. - If the...
-
Ginger Adair is considering an investment in the common stock of a chain of retail department stores. She has narrowed her choice to two retail companies, Lewis Corporation and Ramsey Corporation,...
-
Explain the measurement and reporting of natural resources.} - The cost of natural resources is any cost necessary to acquire and prepare the resource for separation from the earth. - As the natural...
Study smarter with the SolutionInn App