Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
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 Dateint 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 addDaysint days Moves the Date object forward in time by the given number of days
public int daysToDate 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 except when it is divisible by and not so and are not leap years
public String toString returns a String representation of this date in the form daymonthyear
Write a 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.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started