PROGRAM colours IMPLICIT NONE CHARACTER(LEN=10) :: colour INTEGER :: nred = 0, ngreen = 0, nblue = 0, nyellow = 0, & nblack = 0, nwhite = 0, nother = 0 DO READ *, colour colour = TRIM(ADJUSTL(colour)) ! gets rid of leading ! and trailing spaces IF (colour == 'red') THEN nred = nred+1 ELSE IF (colour == 'green') THEN ngreen = ngreen + 1 ELSE IF (colour == 'blue') THEN nblue = nblue + 1 ELSE IF (colour == 'yellow') THEN nyellow = nyellow + 1 ELSE IF (colour == 'black') THEN nblack = nblack + 1 ELSE IF (colour == 'white') THEN nwhite = nwhite + 1 ELSE IF (colour == 'EOF') THEN EXIT ELSE nother = nother+1 END IF END DO PRINT *, 'red =', nred, ' green =', ngreen, & ' blue =', nblue, ' yellow =', nyellow, & ' black =', nblack, ' white =', nwhite, & ' other =', nother END PROGRAM colours