Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class MyDate904
- {
- private int day;
- private int month;
- private int year;
- public MyDate904(int day, int month, int year)
- {
- this.day = day;
- this.month = month;
- this.year = year;
- }
- public MyDate904()
- {
- this.day = 3;
- this.month = 9;
- this.year = 14;
- }
- public int getDay()
- {
- return day;
- }
- public void setDay(int d)
- {
- day = d;
- }
- public int getMonth()
- {
- return month;
- }
- public void setMonth(int m)
- {
- month = m;
- }
- public int getYear()
- {
- return year;
- }
- public void setYear(int y)
- {
- year = y;
- }
- public String dayOfWeek ()
- {
- int q = day;
- int m;
- int y = year;
- if(month==1)
- {
- m = 13;
- y = year-1;
- }
- else if(month==2)
- {
- m = 14;
- y = year-1;
- }
- else
- {
- m = month;
- }
- int k = y%100;
- int j = y/100;
- int h = ( q + ((13*(m + 1))/5) + k + (k / 4) + (j / 4) + 5*j)%7;
- if(h==0)
- {
- return "Saturday";
- }
- else if(h==1)
- {
- return "Sunday";
- }
- else if(h==2)
- {
- return "Monday";
- }
- else if(h==3)
- {
- return "Tuesday";
- }
- else if(h==4)
- {
- return "Wednesday";
- }
- else if(h==5)
- {
- return "Thursday";
- }
- else if(h==6)
- {
- return "Friday";
- }
- else
- {
- return "Error";
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement