PROGRAM MYSTRINGS C C Define variables. C INTEGER IOUT, AGE, BYEAR, VALUES(8) CHARACTER CITY*20, STATE*16, OUTPUT*40 CHARACTER DATE*8, TIME*10, ZONE*5 C C Get information from the keyboard. C PRINT *, 'Enter the name of your birth city:' READ (*, 10) CITY PRINT *, 'Enter the name of your birth state:' READ (*, 10) STATE PRINT *, 'Enter the year of your birth:' READ (*, 20) BYEAR C C Get the current date from the computer and calculate your age. C VALUES(1) contains the current year. C CALL DATE_AND_TIME(DATE, TIME, ZONE, VALUES) AGE = VALUES(1) - BYEAR C C Display the output, first in raw form. C WRITE(*, 30) CITY, STATE, BYEAR WRITE(*, 50) AGE C C Now print the required output in the "pretty" format requested in the C description above. The logic below assumes that the city name is only C one word. C IOUT = 1 DO 100 I = 1, 20 IF (CITY(I:I) .NE. ' ') THEN OUTPUT(IOUT:IOUT) = CITY(I:I) IOUT = IOUT + 1 ENDIF 100 CONTINUE OUTPUT(IOUT:IOUT+1) = ', ' IOUT = IOUT + 2 DO 110 I = 1, 16 IF (STATE(I:I) .NE. ' ') THEN OUTPUT(IOUT:IOUT) = STATE(I:I) IOUT = IOUT + 1 ENDIF 110 CONTINUE C C Subtract IOUT by 1 to get back to the actual number of characters C in OUTPUT. C IOUT = IOUT - 1 C PRINT *, ' ' WRITE(*, 40) OUTPUT(1:IOUT), BYEAR WRITE(*, 50) AGE C C Format statements. C 10 FORMAT(A) 20 FORMAT(I4) 30 FORMAT(' You were born in ', A20, ', ', A16, ' in ', I4, '.') 40 FORMAT(' You were born in ', A, ' in ', I4, '.') 50 FORMAT(' You are ', I2, ' years old.') C STOP END