import java.util.*;
public class Day
{
public static void main ( String[] args)
{
Scanner sc = new Scanner (System.in);
System.out.print ("Enter the day: ");
int b = sc.nextInt();
if ((b < 1) || (b > 31))
{
System.out.println ("Out of Range");
System.exit(0);
}
System.out.print ("Enter the month: ");
int e = sc.nextInt();
if ((e < 1) || (e > 12))
{
System.out.println ("Out of Range");
System.exit(0);
}
System.out.print ("Enter the year: ");
int f = sc.nextInt();
if ((f < 1900) || (f > 2100))
{
System.out.println ("Out of Range");
System.exit(0);
}
// Takes the users responses and establishes the parameters for allowable day, month and year inputs.
int a = 0;
int q = 0;
if (e >= 3)
{
a = (e - 2);
q = f;
}
else
{
a = (e + 10);
q = (f - 1);
}
//alters the month into the March = 1 etc format
int c = q % 100;
int d = q / 100;
int w = (13 * a - 1 ) / 5;
int x = c / 4;
int y = d / 4;
int z = w + x + y + b + c - 2 * d;
int r = z % 7;
r = (r + 7) % 7;
// calculates the value for the day of the week based on input values
String day;
switch (r)
{
case 0: day = "Sunday"; break;
case 1: day = "Monday"; break;
case 2: day = "Tuesday"; break;
case 3: day = "Wednesday"; break;
case 4: day = "Thursday"; break;
case 5: day = "Friday"; break;
case 6: day = "Saturday"; break;
default: day = "nonexistant"; break;
//changes the numeric value into the string for the day of the week
}
if (q >=2008)
{
System.out.println ("\nThat day will be " + day);
}
else
{
System.out.println ("\nThat day was " + day);
}
//prints out the gramatically correct dau of the week
}
}