CSCI 297 Practice 3

Find the Day of the Week

This program will compute the day of the week for a given date in history. We have a web page on Zeller's Algorithm which explains how to do this.

The program will also calculate the Julian date, that is, the number of the day in the year. (January 1 has Julian date 1 and December 31 has Julian date 365, or 366 in a leap year.) It is not hard to calculate a Julian date, as we know the number of days in each month, and we can detect a leap year.

The program will also calculate the time as a number of seconds into the day. For instance:

      12:00:00 A.M. corresponds to     0 seconds,
       1:00:00 A.M. corresponds to  3600 seconds,  
      12:00:00 P.M. corresponds to 43200 seconds, and
       2:30:00 P.M. corresponds to 52200 seconds.


What does the data look like?

Each line in the input contains a date in the following format:

          the name of a month (9 characters)
          1 blank space
          the day of the month (2 digits)
          1 blank space
          the year (4 digits)
          1 blank space
          a time of day (HH:MM:SS)
          1 blank space
          A for A.M. or P for P.M.

The data is in a file called "data-ec.txt" which you can copy into your own directory.


Processing

Read each line in the input file.

For each line of data, find the day in the week and calculate the number of seconds.

For each line of data, print one line which should include the input values, the day of the week for that date, and the Julian date. Single-space the lines. It should all fit on one page.

The output should have a page heading and column headings. Include your name in the heading, as in "Report prepared by Your Name". Center your output neatly on the page. Leave space between columns.

After you have finished processing the input file, close it and produce a neat list (with a suitable heading), of all the "Friday the 13th" dates in the years 2015 through 2050. Print all the dates for a single year on a single line; there may be one date or more than one. Single-space the lines. This list should all fit on one line.


Notes

Your program should be well structured and properly documented. You may need some subroutines or functions. You probably will need some arrays for names of days and months, etc.

How do we detect leap year? Use the following:

If Year is divisible by 400 then
  Year is a leap year
else 
  if Year is divisible by 100 then
    Year is not a leap year
  else 
    if Year is divisible by 4 then
      Year is a leap year
    else
      Year is not a leap year
    end if
  end if
end if.

If you want, you can devise a function returning true or false to indicate whether a year is a leap year.

You can easily check your work by using a calendar program and running it forward or backward to the desired date. (For instance, Windows includes such a calendar.)

You need to compile, link and run your program, correcting any errors. Name your program "progex.f90". Run the program using input redirection and output redirection, reading the data in "prac3dat.txt" and creating an output file called"prac3out.txt".