Assignment #2 - Easter Dates
Due Monday, Feb. 5 at 3:30 PM
Note: There are two sections to this assignment. Don't forget the questions.
Programming
Your task is to use the below algorithm to write a program that calculates the date of Easter for a given year. The algorithm only works for years between 1900 and 2099, and does not work for the years 1954, 1981, 2049, and 2076. (It can be extended to work for all years, but since this is your first C++ programming assignment, I've given you just the simplest version.) Don't worry about error-checking for this assignment - we'll learn that next week.
This algorithm was originally developed by Carl Friedrich Gauss.
The variable year should be requested from the user. All variables are integers.
v = remainder of (year/19)
w = remainder of (year/4)
x = remainder of (year/7)
y = remainder of (19v + 24)/30
z = remainder of (2w + 4x + 6y + 5)/7
date = y + z + 22
if date is less than 31, then Easter is on March [date]
otherwise,
date = y + z - 9 and Easter is on April [date]
Resources
Here is a list of all the answers given by this algorithm for the years 1900-2099. (For 1954, 1981, 2049, and 2076, both the (wrong) answer given by this algorithm and the accepted date are listed.)
More about the calculation of Easter dates
Questions
Answer the following questions and turn them in with your program. (Either written or typed copies are acceptable, as long as I can read them.)
1. A leap year takes place when the year is divisible by 4, unless the year is divisible by 100 and not by 400.
Write a C++ expression that returns true only if year is a leap year.
2. Simplify the expression:
X && Y || X && !Y
3. Simplify the expression:
!!(!(!X || !Y) && Z)
4. Given X = true, Y = false, and Z = true, evaluate
a) the expression in #2
b) the expression in #3
Requirements
As stated above, you needn't error-check user-entered values to make sure they're in the correct range.
Turn in the following items (this is how it will be for C++ assignments)
answers to questions
printed source code
executable file (.exe) on disk or on my computer. (This file can be found in the Debug folder inside your project's folder if you're using MSVC.)
you may turn in electronic copies of source code, workspace files, etc. This is completely optional, but if your program doesn't work properly, it may be beneficial to you if I can find and easily fix what was wrong.
Main Page