This is java and make simple program. Thanks P4.2 Easter Sunday is the first Sun
ID: 3756817 • Letter: T
Question
This is java and make simple program. Thanks
P4.2 Easter Sunday is the first Sunday after the first full moon of spring. To compute the date, you can use this algorithm, invented by the mathematician Carl Friedrich Gauss in 1800: 1. Let y be the year (such as 1800 or 2001). 2. Divide y by 19 and call the remainder a. Ignore the quotient. 3. Divide y by 100 to get a quotient b and a remainder c. .Divide b by 4 to get a quotient d and a remainder e. 5. Divide b13 by 25 to get a quotient g. Ignore the remainder. 6. Divide 19b d-g 15 by 30 to get a remainder h. Ignore the quotient. 7. Divide c by 4 to get a quotient j and a remainder k. 8. Divide a by 319 to get a quotient m. Ignore the remainder. 9. Divide 2 e+2*j -k-h+m+32 by 7 to get a remainder r. Ignore the quotient. 10. Divide hm90 by 25 to get a quotient n. Ignore the remainder. 11. Divide h-m n+19 by 32 to get a remainder p. Ignore the quotient. Then Easter falls on day p of month n. For example, if y is 2001: n4 b 20, c-1 h 18 r 6 P 15 Programming Projects 171 Therefore, in 2001, Easter Sunday fell on April 15. Write a program that prompts the user for a year and prints out the month and day of Easter SundayExplanation / Answer
import java.util.*;
import java.io.*;
class Ideone
{
public static void main (String[] args) throws IOException
{
// your code goes here
int y,a,b,c,d,e,g,h,j,k,m,r,n,p,flag;
y=a=b=c=d=e=g=h=j=k=m=r=n=p=flag=0;
String month="";
Scanner sc= new Scanner(System.in);
System.out.print("Enter the Year: ");
y=sc.nextInt();
a = y % 19;
b = y / 100;
c = y % 100;
d = b / 4;
e = b % 4;
g = ((8 * b + 13) / 25);
h = ((19 * a + b - d - g + 15) % 30);
j = c / 4;
k = c % 4;
m = ((a + 11 * h) / 319);
r = ((2 * e + 2 * j - k - h + m + 32) % 7);
n = ((h - m + r + 90) / 25);
p = ((h - m + r + n + 19) % 32);
switch(n)
{
case 1: month="January";
break;
case 2: month="Feburary";
break;
case 3: month="March";
break;
case 4: month="April";
break;
case 5: month="May";
break;
case 6: month="June";
break;
case 7: month="July";
break;
case 8: month="August";
break;
case 9: month="September";
break;
case 10: month="October";
break;
case 11: month="November";
break;
case 12: month="December";
break;
default: flag = 1;
break;
}
if(flag == 0)
{
System.out.println("In "+y+" Easter Sunday fell on "+month+" "+p);
}
else
{
System.out.println("Invalid Inputs!!! Please restart");
}
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.