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 :
  1. The average of the positive numbers
  2. The largest and the smallest positive number
  3. How many positive numbers are in the file
  4. The average of the negative numbers
  5. The largest and the smallest negative number
  6. How many negative numbers are in the file
  7. 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 :

  1. You must use the the name flow.dat for the name of the file containing your data.

  2. 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.

  3. 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