Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

hello can u help me solving this problem ?? \" with java eclipse\" write a class

ID: 3609836 • Letter: H

Question

hello

can u help me solving this problem ??

" with java eclipse"

write a class called Date , this class has four data members, day(int), month (int) , year(int) week day (string) , provide setters& getters for these data members also write a method that takesan int n and finds the day , the month , the year , and the weekday name after adding n days to the current date ( HINT: use anarray to store the week days names and another array to store thenumber of the days in each month of the year) . the method mustprint the information of the new date . write a test main programthat checks the functionality of the class



thanks,,

Explanation / Answer

/* This is the code for the above question */ import java.io.*; import java.lang.*; import java.util.*; public class Date { public int day = 1; public int month = 1; public int year = 2009; public String weekday= "Thursday"; public final String weekdays[ ] = {"Sunday", "Monday", "Tuesday","Wednesday", "Thursday", "Friday", "Saturday"}; public final int[] daysInMonths= {31, 29,31,30,31,30,31,31,30,31,30,31}; public static int InitialDay=5; /* get and set methods */ public int getDay(){ return this.day ; } public void setDay(int day){ this.day=day; } public int getMonth(){ return this.month; } public void setMonth(int month){ this.month= month; } public int getYear(){ return this.year ; } public void setYear(int year){ this.year=year; } public String getWeekday(){ return this.weekday ; } public void setWeekday(String weekday){ this.weekday=weekday; } public void changeDate(int n){ int newday = getDay() + n; int month = getMonth(); int year =getYear(); String weekday = getWeekday(); int daysinmonth = daysInMonths[month-1]; while(newday > daysinmonth) {     newday -= daysinmonth;     if(month < 12) month++;     else {month =1; year++; newday++;}     daysinmonth = daysInMonths[month-1]; } setDay(newday); setMonth(month); setYear(year); int newWeekday = n%7; newWeekday += InitialDay; if(newWeekday > 7) {newWeekday = (newWeekday % 7); } InitialDay = newWeekday; weekday = weekdays[ newWeekday - 1] ; setWeekday(weekday); System.out.println(); System.out.println(" The new date is: " + newday + "-" +month + "-" + year +" and it is " +weekday); } public static void main(String args[]){ Date d = new Date(); d.changeDate(370); }//end of main }//end of class Date /////output for d.changeDate(370); is The newDate is 6-1-2010 and it is Wednesday"