Docsity

Computing the Date of Easter: A C++ Program, Study Guides, Projects, Research of Computer Science

Toggle sidebar
bg1
CISC 181 Project 1
Computing the Date of Easter1
Due: At 12 Midnight, Sunday, Sept. 28. Email your solution to your TA2.
Hardcopy is due at the beginning of lecture on Tues, Sept. 30.
This project is meant to be solved using the material covered in lecture to
date and in chapters 1 and 2 of the D&D text.
The date for any Easter Sunday from 1982 to 2048 can be computed as
follows (all variables are of type int).
A is year mod 19.
B is year mod 4.
C is year mod 7.
D is (19A+ 24) mod 30.
E is (2B+ 4C+ 6D+ 5) mod 7.
Easter Sunday is March (22 + D+E) (Note that this can give a date in
April. Be sure to change the month and day in this case). You may use single
letter variables, as above, for the given formulas, but choose your other variable
names to make them descriptive of their role in the program. Use lower and
upper case along with the underscore character to make multi-word variable
names easier to read and understand.
This algorithm can be extended to work for any year from 1900 to 2099.
There are four special years, 1954, 1981, 2049, and 2076 for which the algorithm
gives a date that is 7 days later than it should be.
Write a C++ program that computes the date of Easter for a given year.
The program should prompt for the year (between 1900 and 2099 inclusive) then
prints a calendar of the month of Easter Sunday for that year. For example:
Enter the year for which you desire to know the date of Easter: 1985
Easter is Sunday, April 7, in 1985.
April 1985
Sun Mon Tues Wed Thur Fri Sat
123456
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30
1This project is adapted from an exercise on p. 185 of N. Dale and C. Weems, Intro. to
Pascal and Structured Design, 3rd edition.
2That is, to Greg Waltz ([email protected]) for the 9:30AM sections; to Brad
Durandetta ([email protected]) for the 12:30PM sections, and to Staci Lyvers
([email protected]) for the 2:00PM sections.
1
pf3

Partial preview of the text

Download Computing the Date of Easter: A C++ Program and more Study Guides, Projects, Research Computer Science in PDF only on Docsity!

CISC 181 Project 1

Computing the Date of Easter^1

Due: At 12 Midnight, Sunday, Sept. 28. Email your solution to your TA^2. Hardcopy is due at the beginning of lecture on Tues, Sept. 30.

This project is meant to be solved using the material covered in lecture to date and in chapters 1 and 2 of the D&D text. The date for any Easter Sunday from 1982 to 2048 can be computed as follows (all variables are of type int). A is year mod 19. B is year mod 4. C is year mod 7. D is (19A + 24) mod 30. E is (2B + 4C + 6D + 5) mod 7. Easter Sunday is March (22 + D + E) (Note that this can give a date in April. Be sure to change the month and day in this case). You may use single letter variables, as above, for the given formulas, but choose your other variable names to make them descriptive of their role in the program. Use lower and upper case along with the underscore character to make multi-word variable names easier to read and understand. This algorithm can be extended to work for any year from 1900 to 2099. There are four special years, 1954, 1981, 2049, and 2076 for which the algorithm gives a date that is 7 days later than it should be. Write a C++ program that computes the date of Easter for a given year. The program should prompt for the year (between 1900 and 2099 inclusive) then prints a calendar of the month of Easter Sunday for that year. For example:

Enter the year for which you desire to know the date of Easter: 1985

Easter is Sunday, April 7, in 1985.

April 1985 Sun Mon Tues Wed Thur Fri Sat 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30

(^1) This project is adapted from an exercise on p. 185 of N. Dale and C. Weems, Intro. to Pascal and Structured Design, 3rd edition. (^2) That is, to Greg Waltz ([email protected]) for the 9:30AM sections; to Brad Durandetta ([email protected]) for the 12:30PM sections, and to Staci Lyvers ([email protected]) for the 2:00PM sections.

Enter the year for which you desire to know the date of Easter: 1986

Easter is Sunday, March 30, in 1986.

March 1986 Sun Mon Tues Wed Thur Fri Sat 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31

The output must be in the exact format shown. The month heading must be centered in a field of width 35 columns. Note that the dates in the monthly calendar are right-justified in fields of width 5 which allows for nice and easy use of the setw parameterized stream manipulator. For an example of the use of setw, see Fig. 2.21. Each date is right-justified under each day header with the exception of the Tues and Thur headers. Hand-in a single file containing the following: email the file to your TA. The file can be created using the Unix command script as done previously in lab.

  1. A completed cover sheet (see the file $CLASSHOME/programming-projs/coversheet). Please note the distri- bution of points on the coversheet that shows how the project will be graded. Be sure to edit the file to include your name and the assignment number, PP #1.
  2. A listing of your program with appropriate comments and formatting. Use the programs given in class and in the text as models. Use the Unix command cat to list the file containing your program.
  3. A script file of enough runs of test data to verify that the program is correct. Remember that the program may be run multiple times after it is compiled once.
  4. That is, execute the following Unix commands:

CIS181> cat a-completed-cover-sheet-file CIS181> cat your-program-file-name # This lists your program.

CIS181> CC your-program-file-name # Compile your program.

CIS181> a.out # Now execute your program

CIS181> exit # Exit script

E-mail the resulting file, named typescript, to your TA. Print a copy of the typescript file and submit the hardcopy in lecture on Tuesday, Sept