Computer Science 1107
AN INTRODUCTION TO FORTRAN PROGRAMMING FOR SCIENTISTS AND ENGINEERS

Fall 2001

Programming Assignment 4
Due date: Wednesday, October 3, 2001



Objective: To further explore writing FORTRAN 77 programs using selective execution and the logical type.

A. Modified Text Problem 10, page 158.

Write a FORTRAN program that takes a year (after 1582) as input and outputs the number of days in the year after calculating whether or not it is a leap year.
If the user inputs a year prior to 1582, your program should output a message explaining why your program does not accept such input. Your program should not compute with such a value.

See the United Kingdom's Royal Observatory for a clear and consise description of which years are leap years.

  1. Create a hand-drawn flow chart for the program using the appropriately shapes boxes for start-stop, Input/Output, and computation as discussed in class OR write out the algorithm for the entire program using pseudocode which should be written out by hand, not typed.

  2. Write the FORTRAN program, naming the source code file lab4a.f and including an explicit list of all Input and Output variables as well as a short description of the problem in a documentation section using comment lines at the beginning of the program. Be careful to choose the types of your variables appropriately and to include the names and student numbers of all authors in the documentation section.

  3. Run your program with each of the following years as input:
    2000, 2001, 2408, 1492, 1900, 1200

  4. Display your results in a single sentence such as:
    "The year    2000   is a leap year, so it has 366 days."
    Note: You need not worry about the spacing in the sentence--we will learn formatting later.

  5. Check your results by hand before creating your script file.

    B. Modified Text Problem 8, page 174.

    In a certain region, pesticide can be sprayed from an airplane only if the tempreature is at least 70 degrees Farenheit, the relative humidity is between 15 and 35 percent, and the wind speed is at most 10 miles per hour. Write a program that accepts temperature, relative humidity, and wind speed as input and sets a logical variable called PESTOK to either true or false according to the input criteria. Finally, your program should inform the user in a single sentence whether or not conditions permit pesticide to be sprayed.
    1. Create a hand-drawn flow chart for the program using the appropriately shapes boxes for start-stop, Input/Output, and computation as discussed in class OR write out the algorithm for the entire program using pseudocode which should be written out by hand, not typed.

    2. Write the FORTRAN program, naming the source code file lab4b.f and including an explicit list of all Input and Output variables as well as a short description of the problem in a documentation section using comment lines at the beginning of the program. Be careful to choose the types of your variables appropriately and to include the names and student numbers of all authors in the documentation section.

    3. Run the program with sufficiently many carefully selected sets of input to demonstrate the correctness of your algorithm. (This will take quite a few runs, so credit will be assigned for thoughtful testing.)

    4. Display your results in a single sentence.

    5. Check your results before creating your script file.

      Then hand in the following for each of your two programs:

      • The flow chart OR the pseudocode listing.
      • A script file containing all of the following:
        • A printout of the source program obtained by using the UNIX cat command
        • A compilation of the program obtained by using the f77 command
        • Results of execution the program with the given data sets obtained by using a.out
      • A brief paragraph discussing your conclusions about the utility of selective execution in these two FORTRAN programs.


      Recall: For this and all programming assignments you should follow good software engineering principles including documenting your program with comments and using meaningful names for variables. Failure to do this will lead to reduced credit.

      For this and subsequent assignments, you have the option of working in teams of two people. In this case, turn in one copy of your results with both names and student numbers included on every page of every item submitted.



      Course Policies Tentative Schedule Help and References
      Assignments Grades and Announcements Home