Question:
help with java program...?
anonymous
2011-10-06 19:27:55 UTC
program must be called easter....from start to finish.. (entire thing)
1. let y be the year
2.divide y by 19 and call remainder a ignore quotient.
3.divide y by 100 to get quotient b and remainder c
4.divide b by 4 to get quotient d and remainder e
5.divide 8*b+13 by 25 to get a quotient g. ignore remainder
6.divide 19*a+b-d-g+135 by 30 to get remainder h. ignore quotient.
7.divide c by 4 to get a tuotient j and remainder k
8.divide a+11*h by 319 to get a quotient m. ignore the remainder.
9.divide 2*e+2*j-k-h+m+32 by 7 to get remainder r. ignore quotient.
10.divide h-m+r+90 by 25 to get quotient n. ignore remainder.
11.divide h-m+r+n+19 by 32 to get a remainder p. ignore quotient
Three answers:
hariss
2011-10-06 20:00:10 UTC
Guess this ll help u,



Date result = null;



int a = year % 19;

int b = year / 100;

int c = year % 100;

int d = b / 4;

int e = b % 4;

int f = ( b + 8 ) / 25;

int g = ( b - f + 1 ) / 3;

int h = ( 19 * a + b - d - g + 15 ) % 30;

int i = c / 4;

int k = c % 4;

int l = (32 + 2 * e + 2 * i - h - k) % 7;

int m = (a + 11 * h + 22 * l) / 451;

int p = (h + l - 7 * m + 114) % 31;



int month = ( h + l - 7 * m + 114 ) / 31;

int day = p + 1;



GregorianCalendar gc = new GregorianCalendar(year, month - 1, day);

result = gc.getTime();



return result;



--------------



If u are a advanced programmer try this too,



import java.util.Calendar;

import java.util.GregorianCalendar;

public class Easter {



public static final Calendar findHolyDay(int year) {

if (year <= 1582) {

throw new IllegalArgumentException(

"Algorithm invalid before April 1583");

}

int golden, century, x, z, d, epact, n;



golden = (year % 19) + 1; /* E1: metonic cycle */

century = (year / 100) + 1; /* E2: e.g. 1984 was in 20th C */

x = (3 * century / 4) - 12; /* E3: leap year correction */

z = ((8 * century + 5) / 25) - 5; /* E3: sync with moon's orbit */

d = (5 * year / 4) - x - 10;

epact = (11 * golden + 20 + z - x) % 30; /* E5: epact */

if ((epact == 25 && golden > 11) || epact == 24)

epact++;

n = 44 - epact;

n += 30 * (n < 21 ? 1 : 0); /* E6: */

n += 7 - ((d + n) % 7);

if (n > 31) /* E7: */

return new GregorianCalendar(year, 4 - 1, n - 31); /* April */

else

return new GregorianCalendar(year, 3 - 1, n); /* March */

}



/** Main program, when used as a standalone application */

public static void main(String[] argv) {



if (argv.length == 0) {

int thisYear = new GregorianCalendar().get(Calendar.YEAR);

Calendar c = Easter.findHolyDay(thisYear);

System.out.println(c.getTime());

} else

for (int i = 0; i < argv.length; i++) {

int year = 0;

try {

year = Integer.parseInt(argv[i]);

System.out.println(Easter.findHolyDay(year).getTime());

} catch (IllegalArgumentException e) {

System.err.println("Year " + argv[i] + " invalid ("

+ e.getMessage() + ").");

}

}

}

}
lafon
2016-11-12 01:37:46 UTC
Why roll your individual whilst there is in all probability a calendar widget you could reuse? by utilising the way, the Java API itself provides many sensible training and interfaces: Date, Calendar, GregorianCalendar, DateFormat, and SimpleDateFormat.
modulo_function
2011-10-06 19:33:43 UTC
I don't see a program that I can help you with. I see what looks like an assignment.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...