You have been provided with two classes, a Runner class with a main method that you...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
You have been provided with two classes, a Runner class with a main method that you can use to test your code, and the scaffold of a Date class. The date class includes three private int data members called day, month and year. Your task is to complete the Date class according to the following functionality requirements: • A constructor that takes no parameters and sets the day to 1, month to 1 and year to 1901. • A constructor that takes three int parameters and sets the day to the first parameter, the month to the second parameter and the year to the third parameter. ⚫ A getDay method that returns the day. ⚫ A getMonth method that returns the month. A getYear method that returns the year. • A toString method that returns a String in the following format: <day>/<month>/<year> Description For example, if I was to run the following code in the main method in the Runner class: Date d1 = new Date(); System.out.println(d1.getDay()); System.out.println(dl.getMonth()); System.out.println(dl.getYear()); System.out.println(d1); I would expect the following output to be printed to the console: 1 1 1901 1/1/1901 If I was to run the following code in the main method: Date d2 = new Date (19, 10, 2022); System.out.println(d2.getDay()); System.out.println(d2.getMonth()); System.out.println(d2.getYear()); System.out.println(d2); Workspace I would expect the following output to be printed to the console: 19 10 2022 19/10/2022 2 34567820 1234567 9 10 11 + Runner.java 1 public class Runner { 17 } Date.java public static void main(String[] args) { } // You can use the main method to test your class. // Date d1 = new Date(); // System.out.println(d1.getDay()); // System.out.println(d1.getMonth()); // System.out.println(d1.getYear()); // System.out.println(d1); // Date d2 = new Date (19, 10, 2022); // System.out.println(d2.getDay()); // System.out.println(d2.getMonth()); // System.out.println(d2.getYear()); // System.out.println(d2); /home/Runner.java Spaces: 4 (Auto) Console [] All changes saved ► Run Mark + Runner.java 1 public class Date { 2 3 private int day%;B 4 private int month; Date.java 56982 7 91 private int year; // Complete this class according the functionality requirements. /home/Date.java Spaces: 4 (Auto) Console All changes saved Run ✓ Mark * You have been provided with two classes, a Runner class with a main method that you can use to test your code, and the scaffold of a Date class. The date class includes three private int data members called day, month and year. Your task is to complete the Date class according to the following functionality requirements: • A constructor that takes no parameters and sets the day to 1, month to 1 and year to 1901. • A constructor that takes three int parameters and sets the day to the first parameter, the month to the second parameter and the year to the third parameter. ⚫ A getDay method that returns the day. ⚫ A getMonth method that returns the month. A getYear method that returns the year. • A toString method that returns a String in the following format: <day>/<month>/<year> Description For example, if I was to run the following code in the main method in the Runner class: Date d1 = new Date(); System.out.println(d1.getDay()); System.out.println(dl.getMonth()); System.out.println(dl.getYear()); System.out.println(d1); I would expect the following output to be printed to the console: 1 1 1901 1/1/1901 If I was to run the following code in the main method: Date d2 = new Date (19, 10, 2022); System.out.println(d2.getDay()); System.out.println(d2.getMonth()); System.out.println(d2.getYear()); System.out.println(d2); Workspace I would expect the following output to be printed to the console: 19 10 2022 19/10/2022 2 34567820 1234567 9 10 11 + Runner.java 1 public class Runner { 17 } Date.java public static void main(String[] args) { } // You can use the main method to test your class. // Date d1 = new Date(); // System.out.println(d1.getDay()); // System.out.println(d1.getMonth()); // System.out.println(d1.getYear()); // System.out.println(d1); // Date d2 = new Date (19, 10, 2022); // System.out.println(d2.getDay()); // System.out.println(d2.getMonth()); // System.out.println(d2.getYear()); // System.out.println(d2); /home/Runner.java Spaces: 4 (Auto) Console [] All changes saved ► Run Mark + Runner.java 1 public class Date { 2 3 private int day%;B 4 private int month; Date.java 56982 7 91 private int year; // Complete this class according the functionality requirements. /home/Date.java Spaces: 4 (Auto) Console All changes saved Run ✓ Mark *
Expert Answer:
Answer rating: 100% (QA)
Here is the completed Date class based on the requirements provided public class Date Private data m... View the full answer
Related Book For
Statistics For Business And Economics
ISBN: 9780132745659
8th Edition
Authors: Paul Newbold, William Carlson, Betty Thorne
Posted Date:
Students also viewed these 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...
-
Design a Java class that represents a cache with a fixed size. It should support operations like add, retrieve, and remove, and it should evict the least recently used item when it reaches capacity.
-
Q5] A firm has reported a profit of Rs.1,47,000 for the year ended 31-3-2014 after taking into consideration the following items. (i) The cost of an asset Rs.23,000 has been taken as an expense (ii)...
-
Is the price at which a bond would sell in the market without the conversion feature. Market premium Conversion value Straight bond value Strike price value
-
Find the most general antiderivative or indefinite integral. You may need to try a solution and then adjust your guess. Check your answers by differentiation. fox (x + 1) dx
-
William Stem filed an action against Gary Braden, seeking to rescind a contract for the sale of an automobile and to obtain the return of the purchase price plus interest. The trial court granted...
-
Shannon Inc. has been manufacturing its own shades for its table lamps. The company is currently operating at 100% of capacity. Variable manufacturing overhead is charged to production at the rate of...
-
Suppose that both players discount future payoffs with the same discount factor ? < 1. Suppose that both players play the "Cooperative Strategy;" namely, they play C in every period, no matter what...
-
Dry Supply is a wholesaler of dry cleaning equipment, cleaning supplies, and laundry soap. This company is located in Kansas, it has been in business for over 50 years. Anne Schippel, is a business...
-
Your futures account had equity of $20,000.00 at the start. Given the following positions, what is the account's CURRENT equity balance? POSITIONS Sep Wheat Dec Gold Dec Cocoa Cash TOTAL QTY 5 1 2...
-
Create 4 new classes as are detailed in below requirements. 2. In the Results Entry class, create: private instance variables named count (int) and target (char). A single constructor that accepts...
-
Part A A concert loudspeaker suspended high off the ground emits 34 W of sound power. A small microphone with a 1.0 cm area is 40 m from the speaker. What is the sound intensity at the position of...
-
David is a supervisor at a chemical manufacturing plant. He wishes to see, on a continuous basis, whether the temperature readings from one of the oxygen tanks is within the desired parameters. What...
-
Module 2 Discussion: Evaluating the Impact of Current ASUs Evaluating the Impact of Current ASUs What are secondary sources of US GAAP and how can they be used to help a researcher? Submission...
-
Can someone help me with this question? /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the...
-
XYZ Ltd. is a health foods distributor and retailer initiated a customer loyalty program that offers member points to redeem a bottle of its X-Premium wine. The premium wine costs the company $30 per...
-
On January 1, 2017, McIlroy, Inc., acquired a 60 percent interest in the common stock of Stinson, Inc., for $340,200. Stinson's book value on that date consisted of common stock of $100,000 and...
-
What are the model constant and the slope coefficient of x1 when the dummy variable equals 1 in the following equations, where x1 is a continuous variable and x2 is a dummy variable with a value of 0...
-
Consider again the data at the time of the first interview 1daycode = 12 for participants in the HEI-2005 study (Guenther et al. 2007). Find a 95% confidence interval estimate of the difference in...
-
A fast-food chain decided to carry out an experiment to assess the influence of advertising expenditure on sales. Different relative changes in advertising expenditure, compared to the previous year,...
-
Oxford Corporation began operations in 2015 and reported pretax financial income of 225,000 for the year. Oxfords tax depreciation exceeded its book depreciation by 40,000. Oxfords tax rate for 2015...
-
At December 31, 2015, Suffolk Corporation had an estimated warranty liability of 105,000 for accounting purposes and 0 for tax purposes. (The warranty costs are not deductible until paid.) The...
-
State whether each of the following events will result in a movement along General Motors (GMs) demand curve for labor in their U.S. automobile factories or whether it will cause its demand curve for...
Study smarter with the SolutionInn App