PROGRAM average1 ! ! Author: Br. David Carlson ! ! Date: February 7, 2000 ! ! Revised: May 2, 2004 ! ! This program prompts the user to enter floating point numbers, with 0 ! used to indicate the end of data. The average of the numbers (not ! including the 0) is calculated and printed. IMPLICIT NONE REAL::sum, item, average INTEGER::count count = 0 sum = 0.0 DO WRITE (*, *) 'Enter a float (or 0 to quit)' READ (*, *) item IF (item == 0.0) THEN EXIT END IF sum = sum + item count = count + 1 END DO IF (count > 0) THEN average = sum / count ELSE average = 0.0 END IF WRITE (*, *) 'Average = ', average END PROGRAM