Cmpsc 101, Project Average and Extremes
Write a program ( filename : flow.pl ) which can read from a data file
( filename : flow.dat ) numbers and calculates and prints out :
- The average of the positive numbers
- The largest and the smallest positive number
- How many positive numbers are in the file
- The average of the negative numbers
- The largest and the smallest negative number
- How many negative numbers are in the file
- The number of lines in the file which contain a 0 (zero )
The data file will contain 1 number per line but your program
must be able to perform its functions regardless of
how many lines/numbers the file will contain.
Your program should also contain
a check making sure that the sum of the results from 3. and 6. and 7..
is equal to the number of lines your program read.
Important :
- You must use the the name flow.dat for the name of the file containing your
data.
- You create your file flow.dat with numbers you decide upon. It is your
responsibility to make sure that your numbers test out all possibilities
of numbers. I will test your program on a data file of my choosing.
- Please do NOT submit your data file flow.dat to ANGEL.
Zig Herzog; hgn@psu.edu
Send a Note to Zig
Last revised: 09/29/04