Question: this is what i have so far i only need help with adding the daysTo to my code so i can recieve it in the



Write a class called Date that represents a date consisting of a year, month, and day. A Date object should have the following methods public Date (int year, int month, int day) Constructs a new Date object to represent the given date public void addDays (int days) Moves this Date object forward in time by the given number of days. public void addWeeks (int weeks) Moves this Date object forward in time by the given number of seven-day weeks. public int days To (Date other) Returns the number of days that this Date must be adjusted to make it equal to the given other Date. public int getDay Returns the day value of this date for example, for the date 2006/07/22, returns 22. public int getMonth() Returns the month value of this date, for example, for the date 2006/07/22, returns 7 public int getYear() Returns the year value of this date, for example, for the date 2006/07/22, returns 2006 public boolean isLeap Year Returns true if the year of this date is a leap year. A leap year occurs every four years, except for multiples of 100 that are not multiples of 400. For example, 1956, 1844, 1600, and 2000 are leap years, but 1983. 2002. 1700, and 1900 are not public String toString() Returns a String representation of this date in year/month/day order, such as "2006/07/22" Due Tuesday 1/12 pg. 584 #2 Don't forget to write the client program to create 3 dates one of which is a leap year, and use all the methods addDay, addWeeks, daysTo, isleapYear. Ex: 2/29/19 not a leap year. 2/28/19 add a day 3/1/191/21/19 add a week 1/28/19 2/20/19 days to 3/12/19 is 19 days las Date 2 4 private int month; private int day, private int years 8 public Date (int theYear, int theMonth, int theDay) 9 10 month the Month; 11 day-theDay: 12 year-theYear; 13 3 14 15 public String toString() 16 17 return month day year; 18 } 19 20 21 public int getDay () 22 - 25 return days 24 25 26 27 public int getMonth ( 28 29 return month; 30 31 32 33 public int getYear ( 34 35 return years 36 32 38 39 public boolean isleapYear() 4e. 41 if(year40) 42 return true; 43 else 64 return false; 46 47 48 49 58 public void addDays (int days) int month days if (months.2) month day 28, else if(month month 6 month 9 months) anth days 30 month days 31 42 return true; else return false; 44 46 47 48 public void addDays (int days) 49 50 int month days; 51 52 if(month2) 53 month days - 28; 54 else if(month-4 limonth month month.-1) 55 month days -303 56 57 month_days 31: 58 day days; 59 while (day > 365) 61 62 day 365: 63 > 64 while (day> month days) 65 66 day-month_days: 67 month (month > 12) 69- 70 month 71 1 72 73 74 > 75 public void addileeks (int weeks) 76 77 78 addDays (7 weeks); 79 80 > 51 > 82 83 public class DateDemo 34 85 public static void main(String[] args) 86 87 Date dti new Date (2010,12,23) 200 System.out.println("Dates"-uti); 90 91 ati.adoDays(); 92 System.out.println("After adding days.dt1); ati.addweeks (1) System.out.printin("After adding 1 week adta); 96 97 98 99 if(at1.isleap Year() 101 System.out.println("Leap ya System.out.printint la year) 105 10
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
