Advertisement
Guest User

Hw #5 Nicholas Talbot

a guest
Sep 29th, 2014
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //Nicholas Talbot
  2. //9-27-14
  3. //Into Java Programming CSCI-111
  4. //HW #5
  5. //To write a program to compute the date of Easter Sunday.
  6. //Natalbot0001@student.stcc.edu
  7. import java.util.Scanner;
  8. public class Easter {
  9.  
  10.     public static void main(String[] args) {
  11.         Scanner input = new Scanner(System.in);
  12.         System.out.print("Enter Year");
  13.         int y = input.nextInt();
  14.         // Let y be the year (such as 1800 or 2001).
  15.        
  16.              
  17.        
  18.                 // Divide y by 19 and call the remainder a. Ignore the quotient.
  19.        
  20.                 int a = y % 19;
  21.        
  22.                 // Divide y by 100 to get a quotient b and a remainder c.
  23.        
  24.                 int b = y / 100;
  25.        
  26.                 int c = y % 100;
  27.        
  28.                 // Divide b by 4 to get a quotient d and a remainder e.
  29.        
  30.                 int d = b / 4;
  31.        
  32.                 int e = b % 4;
  33.        
  34.                 // Divide 8 * b + 13 by 25 to get a quotient g. Ignore the remainder.
  35.        
  36.                 int g = (8 * b + 13) / 25;
  37.        
  38.                 // Divide 19 * a + b - d - g + 15 by 30 to get a remainder h. Ignore the quotient.
  39.        
  40.                 int h = (19 * a + b - d - g + 15) % 30;  // not sure wich ways the parenthesis go here
  41.        
  42.                 // Divide c by 4 to get a quotient j and a remainder k.
  43.        
  44.                 int j = c / 4;
  45.        
  46.                 int k = c % 4;
  47.        
  48.                 // Divide a + 11 * h by 319 to get a quotient m. Ignore the remainder.
  49.        
  50.                 int m = (a + 11 * h) / 319;    // again which order for the operations needs parenthesis
  51.        
  52.                 // Divide 2 * e + 2 * j - k - h + m + 32 by 7 to get a remainder r. Ignore the quotient.
  53.        
  54.                 int r = (2 * e + 2 * j - k - h + m + 32) % 7;
  55.        
  56.                 // Divide h - m + r + 90 by 25 to get a quotient n. Ignore the remainder.
  57.        
  58.                 int n = (h - m + r + 90) / 25;
  59.        
  60.                 // Divide h - m + r + n + 19 by 32 to get a remainder p. Ignore the quotient.
  61.        
  62.                 int p = (h - m + r + n + 19) % 32;
  63.          
  64.        
  65.             }
  66.         public int getEasterSundayMonth(){
  67.          return n;
  68.         }
  69.         public int getEasterSundayDay(){
  70.             return p;
  71.         }
  72.         System.out.println("Easter Falls on")+ n;}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement