SUBROUTINEs

    PROGRAM compute_change
      INTEGER :: change, price, amount, np, n50, n20, n10, n5, n2, n1

      WRITE(UNIT=*, FMT=*) 'Type in price...'
      READ(UNIT=*, FMT=*) price
      WRITE(UNIT=*, FMT=*) 'Type in amount handed over...'
      READ(UNIT=*, FMT=*) amount

      change = amount - price

      CALL calc_change(change, np, n50, n20, n10, n5, n2, n1)

      WRITE(UNIT=*, FMT=*) 'Change = ', np,  ' pounds', &
                                        n50, ' 50s,', n20, ' 20s,', &
                                        n10, ' 10s,', n5,  ' 5s,', &
                                        n2,  ' 2s,',  n1,  ' 1s.'
    END PROGRAM compute_change

    ! -- subprogram to compute coins needed:

    SUBROUTINE calc_change(change, np, n50, n20, n10, n5, n2, n1)
      INTEGER, INTENT(IN)  :: change                          ! -- INput
      INTEGER, INTENT(OUT) :: np, n50, n20, n10, n5, n2, n1   ! -- OUT going

      INTEGER :: remainder

      remainder = change

      np  = remainder/100
      n50 = remainder/50
      ...
    END SUBROUTINE 


...previousup (conts)next...



About this document:

Produced from the SGML: /home/isd/public_html/_course_fortran_90/_reml_grp/index.reml
On: 10/2/2003 at 10:33:52
Options: reml2 -i noindex -l long -o html -p multiple