Easter
unknown
java
4 years ago
2.2 kB
14
Indexable
/**
* This program implements the algorithm created by Fredrich Gauss
* for determining the date of Easter
*
* @author: <Lauren-Bayley McDaniel>
* @date: <Feb 4, 2022>
*/
import java.util.Scanner;
public class Easter{
public static void main(String[] args){
// call our scanner
Scanner input = new Scanner(System.in);
System.out.println("What year would you like to track down the Easter Bunny for?");
// compute Carl Friedrich Gauss's weird calculation for finding Easter
// Future LB: one thing that worked really well was doing the calculation first, then going to your while loops
int y = input.nextInt();
int a = y % 19;
int b = y / 100;
int c = y % 100;
int d = b / 4;
int e = b % 4;
int g = (8*b+13)/25;
int h = (19*a+b-d-g+15)%30;
int j = c / 4;
int k = c % 4;
int m = (a+11*h)/319;
int r = (2*e+2*j-k-h+m+32) % 7;
int n = (h-m+r+90)/25;
int p = (h-m+r+n+19)%32;
// n=month Easter falls on, so we set it to string variable "April" with a "March" if loop exception of n=3
String month="April";
if(n==3)
month = "March";
//y = our year. Let's get fancy and say something about years in the future, the past, and our algorithm-sake Gauss's
String year ="How do you celebrate Easter?";
if (y>=2022)
year = ". Where do you plan on being that far in the future?";
if (y>=1777 && y<1855)
year = " This year was during the life of Carl Friedrich Gauss, the mathemetician who created the algorithm to find what day Easter falls on based on the year. I thought this was odd, so I dug into it. As it so happened, Gauss's mother was illiterate, and did not know what day Frederich was born on. What she did know was it was a on a Wednesday, eight days before the Feast of Ascension. So he created this algorithm to calculate his own birthday. I find that pretty darn charming.";
// print the results
System.out.println("In " + y + " Easter fell / will fall on " + month + " " + p + "." + year);
//end main method
}
}
Editor is loading...