CSCI 220
HOMEWORK ASSIGNMENT #2
Assigned Date: Thursday, September 11, 2003
Due Date: Wednesday, September 17, 2003
Due Time: Noon

 

Purpose:

This assignment focuses on selection statements and error checking.

Source filename to be submitted:  EasterFinder.java

 

Documentation:

See instructions in the first homework assignment.

 

Assignment: 

Write a program that computes the date for a specific Easter Sunday in the 20th and 21st centuries.   Use the following formula given in pseudocode (all variables are of type int).

a is year % 19
b is year % 4
c is year % 7
d is (19 * a + 24) % 30
e is (2 * b + 4 * c + 6 * d + 5) % 7
Easter Sunday is March (22 + d + e)

(note that the date produced may actually be in April)

 

Sample Run 1: (user input in italics)

Enter a year between 1900 and 2099 (for example 2003): 1985

In 1985, Easter Sunday is on April 7.

 

Sample Run 2: (user input in italics)

Enter a year between 1900 and 2099 (for example 2003): 2301

The year you entered, 2301, is outside the program’s range.

 

Notes:

  1. Follow the above I/O format carefully.
  2. Test your program with different inputs to ensure that it works properly.

 

Submission: 

See instructions in the first homework assignment.

 

References

  1. Adapted from Dale, et al. (1996), “Programming and Problem Solving in C++” D.C. Heath and Co., p. 250