Computer Science
1107
AN INTRODUCTION
TO FORTRAN
PROGRAMMING
FOR SCIENTISTS AND
ENGINEERS
Fall 2001
Programming Assignment 12, the Final Assignment
Due date: Friday, December 14, 2001 in class
No late papers will be accepted.
Objective:
To explore writing a FORTRAN 77 program using text and file
handling.
Modified Text Problem 33, Page 710.
In this problem, you will convert a text file written in MORSE CODE
to English or a text file written in English to MORSE CODE.
Morse Code is currently used in airplane
navigation and for
ham radio
operation.
The Morse Code Alphabet
A  
.-
B  
-...
C  
-.-.
D  
-..
E  
.
F  
..-.
G  
--.
H  
....
I  
..
J  
.---
K  
-.-
L  
.-..
M  
--
|
N  
-.
O  
---
P  
.--.
Q  
--.-
R  
.-.
S  
...
T  
-
U  
..-
V  
...-
W  
.--
X  
-..-
Y  
-.--
Z  
--..
|
0  
-----
1  
.----
2  
..---
3  
...--
4  
....-
5  
.....
6  
-....
7  
--...
8  
---..
9  
----.
|
Period  
.-.-.-
Comma  
--..--
? Mark  
..--..
- Mark  
-....-
' Mark  
.----.
|
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 lab12.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.
- The user should enter the input and output filenames which may not be
the same. The input file should be OLD and the output file should be NEW.
Output should be written both to the output file and to the screen.
- Use the IOSTAT varibles to test to see if the files are successfully
opened. Use ERR in both cases to print an appropriate message and to
gracefully exit if there are file opening problems.
- Be sure to think about the order of your selective
testing operations. Credit will be
reduced for poor programming practices such as redundant testing.
This means you should give careful thought to your algorithm.
-
The space between MORSE CODE characters is one space
and between words is space slash space or " / ".
So, "A nice day." should be
translated as: ".- / -. .. -.-. . / -.. .- -.--
.-.-.-"
- Be sure to test for correct input from the user. If there is
no possible translation for a given character or set of characters
use * for each.
- Run your program with the following files:
- 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
NO required paragraph this time!.
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 final programming assignment, 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.