Question: JAVA PROGRAMMING Below is the assignment. Please write the code, and the client class (class that will run). Must produce EXACTLY the output attached below!!!

JAVA PROGRAMMING

Below is the assignment. Please write the code, and the client class (class that will run). Must produce EXACTLY the output attached below!!! The only thing that should change in the output is the last line, if I enter different dates into the Scanner.

Write a class called Date that represents a date consisting of a day, month, and year. A date object should have the following methods:

public Date(int day, int month, int year) -- Constructs a new Date object to represent the given date

public int getDay() -- returns the day value of this date

public int getMonth() -- returns the month value of this date

public int getYear() -- returns the year value of this date

public void addDays(int days) -- Moves the Date object forward in time by the given number of days

public int daysTo(Date other) -- Returns the number of days between this Date and the other Date

public boolean isLeapYear() -- Returns true if the year of this Date is a leap year. A leap year occurs when the value of the year is divisible by 4, except when it is divisible by 100 and not 400 (so 1700, 1800, and 1900 are not leap years)

public String toString() -- returns a String representation of this date in the form day/month/year

Write a client program in which to test your class. This program should prompt the user to enter the days, months, and years of two separate dates, and then print out the number of days between these two dates.

The following is one run of your program and their expected output (user input is bold and underlined):

Enter day of first date:19

Enter month of first date:1

Enter year of first date:2197

Enter day of second date:16

Enter month of second date:2

Enter year of second date:2397

There are 73075 days between 19/1/2197 and 16/2/2397

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!