Computer Science
1107
AN INTRODUCTION
TO FORTRAN
PROGRAMMING
FOR SCIENTISTS AND
ENGINEERS
Fall 2001
Programming Assignment 10
Due date: Wednesday, November 21, 2001
Objective:
To explore writing a FORTRAN 77 program using arrays.
Menu-Driven Multi-Purpose List-Processing Program
For this program you are to create a multi-level
menu-driven program to manipulate an
array in a variety of ways. Use subroutines and/or functions to implement the
various menu choices in the program, passing the array as needed.
You may assume that the user will never enter a list with more than
100 numbers, and that no file will have more than 1000 entries.
Your program should have the following functionalites:
- Reading in a list of real numbers, and giving the user the
option of reading from the keyboard or from a file whose name is to
be entered by the user. If this is to be from the keyboard,
giving the user the choice
of entering the size of the list or
a flag value to mark the end of the list. (If reading from a file, the flag
should be assumed to be the end-of the file, so you should not ask the user
for a flag.)
- Sorting the list into ascending order, giving the user the option of
seeing the output on the screen or having it placed into a new file with the
filename given by the user. For the sort, you may use the selection sort
algorithm discussed in class. The code for selection sort is here.
- Finding the mean and standard deviation of the list and outputing them to
the screen. (The formula for
the standard deviation is given in problem 8 on p. 547 of the text.)
- Determining whether or not a user-input number is located in the list
and giving its location in the list if the number appears.
- Quiting the program.
Be sure to do the following:
- Create a hand-drawn flow chart for the program using the appropriately shaped 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.
- Write the FORTRAN program, naming the source
code file lab10.f and including an explicit list of all
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.
- Run the program with sufficiently many carefully selected sets of
input to demonstrate the correctness of your algorithm for each of the menu
choices, including the following:
- Finding the mean and the standard deviation of
the data from the following input file realin.dat,
Assuming that you do not have information about the number of entries.
- Locating 90.2111 and 5.1245 in realin.dat.
- Taking the following 5 inputs from the keyboard:
-17.3, 2.3, 7.1, 9, and 17.5, sorting this data, and outputing the result
into a file
named 'out5.dat.'
- Check your results before creating your script file.
Then hand in the following:
- 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 printout of out5.dat obtained by using the cat command.
- A required paragraph which discusses the utility of arrays.
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 programming 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.