C:\Users\ar114\Documents\NetBeansProjects\Exam1_CalebFontenot\src\main\java\com\calebfontenot\exam1_calebfontenot\DayOfTheWeek.java
/*
 * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
 * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
 */
package com.calebfontenot.exam1_calebfontenot;

import java.util.Scanner;

/**
 *
 * @author ar114
 */
public class DayOfTheWeek {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        System.out.print("\n\n Enter year (e.g. 2008): ");
        int year = input.nextInt();
        System.out.print("Enter month 1-12: ");
        int month = input.nextInt();
        if (month == 1) {
            month = 13;
            year = year - 1;
        }
        else if (month == 2) {
            month = 14;
            year = year - 1;
        }
        System.out.println("Enter the day of the month: 1-31: ");
        int dayOfMonth = input.nextInt();
        
        int j = year / 100;
        int k = year % 100;
        
        int dayOfWeek = (dayOfMonth 
                + 26 * (month + 1) / 10 + k + k / 4 + j / 4 + 5 * j) % 7;
        if (dayOfWeek == 0) {
            System.out.println("Day of the week is Saturday");
        }
        else if (dayOfWeek == 1) {
            System.out.println("Day of the week is Sunday");
        }
        else if (dayOfWeek == 2) {
            System.out.println("Day of the week is Monday");
        }
        else if (dayOfWeek == 3) {
            System.out.println("Day of the week is Tuesday");
        }
        else if (dayOfWeek == 4) {
            System.out.println("Day of the week is Wednesday");
        }
        else if (dayOfWeek == 5) {
            System.out.println("Day of the week is Thursday");
        }
        else if (dayOfWeek == 6) {
            System.out.println("Day of the week is Friday");
        }
    }
}