Fortran: Lesson 3

Lesson topics


View Demos
# 1 # 2 # 3 # 4 # 5 # 6 # 7 # 8 # 9
Download Demos
# 1 # 2 # 3 # 4 # 5 # 6 # 7 # 8 # 9

Demo 9

								        program interest
c       This program computes simple interest.
        real I, P, r
        integer t

        print *, "Enter the amount borrowed (in dollars) :"
        read *, P
        print *, "Enter the annual interest rate :"
        read *, r
        print *, "Enter the number of years of the loan :"
        read *, t

        I = P * r/100 * real(t)
        print *

        write (*,10) "Principal", "Rate", "# Years", "Interest"
 10     format (t5,a,t25,a,t40,a,t55,a)

        write (*,20) "$", P, r, "%", t, "$", I
 20     format (t5,a,f8.2,t25,f4.2,a,t41,i3,t55,a,f8.2)
        end