I'm trying to solve this very basic question that involves some calculation. But my calculation is getting different result. (It returns 6, using the input given in the example, it should return 1 (sunday).
Here's the question:
This is what I am trying:
Scanner sc = new Scanner(System.in);
System.out.println("Enter year: (e.g., 2012): ");
int year = sc.nextInt();
System.out.println("Enter month: 1-12: ");
int month = sc.nextInt();
System.out.println("Enter the day of the month: 1-31: ");
int day = sc.nextInt();
//calculate the day using the forumla
int k = year % 100;
int j = year / 100;
int weekDay = (int)((day + ( 26 * (month + 1))/10.0 + k + k/4.0 + j/4.0 + (5*j)) % 7);
