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 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
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