I'm trying to write an algorithm that allows me to determine what day of the week a given date is. I've seen on internet that I could import the java.util.calendar, but unfortunately I'm not allow to use that; instead I have to create the algorithm myself. This is what I wrote so far, but unfortunately it doesn't work. Any thoughts? Thanks
public class Date{
private int year;
private int month;
private int day;
public String getDayOfTheWeek(){
int JANUARY =1;
int FEBRUARY =4;
int MARCH =4;
int APRIL =0;
int MAY =2;
int JUNE =5;
int JULY =0;
int AUGUST =3;
int SEPTEMBER =6;
int OCTOBER =1;
int NOVEMBER =4;
int DECEMBER =6;
int lastTwoDigits = year % 100;
int lastTwoDigitsDivTwelve = lastTwoDigits/12;
int lastTwoDigitsRemainder = lastTwoDigits %12;
int lastTwoDigitsRemainderDivFour = lastTwoDigitsRemainder/4;
int addDayOfTheMonth = day;
int finalMod = 7;
return (lastTwoDigits + lastTwoDigitsDivTwelve + lastTwoDigitsRemainder + lastTwoDigitsRemainderDivFour + day + month) % finalMod ;
}
}