Answered step by step
Verified Expert Solution
Link Copied!
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 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

blur-text-image
Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

DATABASE Administrator Make A Difference

Authors: Mohciine Elmourabit

1st Edition

B0CGM7XG75, 978-1722657802

More Books

Students explore these related Databases questions

Question

1. Identify six different types of history.

Answered: 3 weeks ago

Question

2. Define the grand narrative.

Answered: 3 weeks ago