Help in creating a java application? writing code? 3. You can compute the date f
ID: 3762109 • Letter: H
Question
Help in creating a java application? writing code?
3. You can compute the date for any Easter Sunday from 1982 to 2048 as follows (all variables are of type int):a is year % 19b is year %4c is year % 7d is (19 * a + 24) % 30e is (2 * b +4 * c +6 * d + s ) x Easter Sunday is March (22 + d + e) For example, Easter Sunday in 1985 is April 7. Write an application that inputs the year and outputs the date (month and day) of Easter Sunday for that year. Note that when the formula gives a value greater than 30, the month is April.Explanation / Answer
#include <stdio.h>
int main()
{
printf("name here" ");
int year;
int a ;
int b ;
int c ;
int d ;
int e ;
int easter_sunday ;
/* Get year from user*/
printf ("Enter year between 1982 and 2048: ") ;
scanf ("%d", &year) ;
a = year % 19 ;
b = year % 4 ;
c = year % 7 ;
d = (19 * a + 24) %30 ;
e = (2 * b + 4 * c + 6 * d + 5) % 7 ;
easter_sunday = (22 + d + e) ;
if (easter_sunday > 31) {
printf("Easter Sunday in %d", year);
printf(" is April %d ", easter_sunday - 31);
}
else {
printf (" Easter Sunday in %d", year);
printf (" is March %d ", easter_sunday);
}
return 0;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.