Computing Magazine

Program To Calculate the Day from the Date Using Zeller’s Congruence.

Posted on the 22 April 2012 by In7rud3r
<a href="http://www.yesadvertising.com">affiliate marketing</a>

Program To Calculate the day from the date using Zeller’s congruence.


//Program To Calculate the day from the date using Zeller's congruence.

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class DayFromDate
{
public static void main(String[] pArgs) throws IOException
{

int tYear = NeilClass.GetInputInt(“Type in the year “);
int tMonth = NeilClass.GetInputInt(“Type in the Month “);
int tDay = NeilClass.GetInputInt(“Type in the Day “);

int a=0;
int b=0;
int c=0;

if (tMonth < 3){
a = tMonth + 10;
b = (tYear-1)%100;
c = (tYear-1)/100;
}
else{
a = tMonth – 2;
b = tYear%100;
c = tYear/100;
}

int tWeekDay = (700 + (((26*a)-2)/10)+tDay+b+b/4+c/4-(2*c))%7;
System.out.println(“The day is ” + tWeekDay);
System.out.println(“[0 is Sunday, 1 is Monday etc.]“);

}
}

<a href="http://www.yesadvertising.com">affiliate marketing</a>

Back to Featured Articles on Logo Paperblog

Magazines