Project 2: Problem Solution

 
 
CSE 1503 Introduction to Computer Programming with FORTRAN

Section 1 & 2 Due Date: March 02, 1999

 

wpe7.jpg (2882 bytes)
PROBLEM

Program Leap Easter (1) takes an INTEGER variable called Year as an input, (2) determines if that year is a leap year, (3) calculates the Easter day of that year, (4) prints the results.

How-To calculate the Leap Year

A year is a leap year either if it is divisible by 4 but not by 100 or divisible by 400. Thus, 1990 is not a leap year since it is not divisible by 4; year 1900 is not a leap year since it is divisible by 4 and by 100; year 1996 is a leap year since it is divisible by 4 but not by 100; and year 2000 is a leap year since it is divisible by 400. Assume that the result of the above condition or test is stored in a LOGICAL variable name called LEAP.

How-To calculate the Easter Day

The Easter Day is the first Sunday after the first full moon, on March 21st or later. However, to write a Fortran program determining Easter Day based on the previous input is not within the scope of this course. 

T. H. O'Berine discovered a simple method to find out the Easter Day between 1900 and 2099 inclusive. Let Year be a year between 1900 and 2099 inclusive. You should calculate both values for Day and Month in order to determine the Easter Day.
 

How-To calculate Day
The following table gives all necessary steps to find the value of Day
Step
Dividend
Divisor
Quotient
Remainder
1
n = Year - 1900
19
 
a
2
7a + 1
19
b
 
3
(11a+4) - b
29
 
m
4
n
4
q
 
5
n + q + (31 - m)
7
 
w
6
Day = 25 - m - w
     
In the table above, the column labeled Dividend is divided by the number in the Divisor column, giving either a quotient or a remainder. The procedure goes as follows: 
    1. In step 1, n is defined to be y - 1900. Then, divide n by 19 and let the remainder be a
    2. In step 2, computing 7a + 1 and dividing the result by 19 yield a quotient b
    3. In step 3, computing (11a + 4) - b and dividing the result by 29 yield a remainder m
    4. In step 4, divide n by 4 and store the quotient in q
    5. In step 5, computing n + q + (31 - m) and dividing the result by 7 yield a remainder w
    6. In step 6, Day is computed as Day = 25 - m - w. Day is used to determine both the month and the day of that month. 


    How-To calculate Month

    To determine the value of Month, follow the rules below: 
     

    1. If Day is greater than or equal to 1, then the Month equals to April. 
    2. If Day is less than 1, the new Day becomes Day + 31 and the Month equals to March. 

    3. For example: If Year is 1997, then Day takes a value of -1 at step 6 above. The new Day becomes Day + 31 = (-1) + 31 = 30 and Month is March. 
    Thus, the Easter Day is the Day on the Month


How should your program works

Allow user to input more than one year on a single execution. If user enters a year not within the range of 1900 and 2099 inclusive, stop program.

OUTPUT EXAMPLES

Enter a Year value between 1900 and 2099 inclusive? 
To quit program enter any value not between 1900 and 2099
1900
Year 1900 Easter Day 4/15 
1901
Year 1901 Easter Day 4/7 
1902
Year 1902 Easter Day 3/30 
1903
Year 1903 Easter Day 4/12 
1904
Year 1904 Easter Day 4/3 Leap 
1905
Year 1905 Easter Day 4/23 
1906
Year 1906 Easter Day 4/15 
1907
Year 1907 Easter Day 3/31 
1908
Year 1908 Easter Day 4/19 Leap 
1909
Year 1909 Easter Day 4/11 
1910
Year 1910 Easter Day 3/27 
1911
Year 1911 Easter Day 4/16 
1912
Year 1912 Easter Day 4/7 Leap
9999
>

NOTES

  • When you ask users for input, let them know what correct values they are supposed to enter. 
  • Include the required header comments and indenting. A suggested style for the header comments is:
PROGRAM Leap Easter
!-------------------------------------------------------------------------------------
! Name: (your name)
! Student ID # : (your id)
!
! (description of the program) 
! Input Variables: (variables list)
! Output Variables: (variables list)
!-------------------------------------------------------------------------------------

IMPLICIT NONE
(program statements)
END PROGRAM Leap Easter

  • Hand in a printout of your source code in class