What is wrong with this fortran code? starting with 10 dollars at 10% return over 30 years
Question:
What is wrong with this fortran code?
starting with 10 dollars at 10% return over 30 years i should have how much money?
!This program calculates the amount of money you would get on this day and time in exactly 30 years
!if you save a given amount of money, at a constant annual rate of return.
!Variable Definitions:
!InitialAmount: money you are willing to save today (dollars)
!Rate: the annual percentage rate you expect to get back(%)
!Time: the number of years money will be allowed to grow before withdrawal
!AmountR: amount of money you are slated to get on this day and time in 30 years (dollars)
!Input: InitialAmount, Rate
!Output: AmountR
IMPLICIT NONE
integer, parameter:: wp = selected_real_kind(15)
real(wp):: InitialAmount, Rate, AmountR
integer:: Time, ioerror
CHARACTER(LEN=30) :: FMT
!prompt user for input
Write (*,*) "Enter initial amount (0 to 100000 dollars) and Rate (0 to 20) separated by a space or comma"
DO
Read (*,*, iostat=ioerror) InitialAmount, Rate
if(ioerror==0 .and. InitialAmount>=0 .and. InitialAmount<=100000 .and. Rate >= 0 .and. Rate<=20) exit
Write(*,*) "Check your input. Enter initial amount (0 to 100000 dollars) and Rate (0 to 20) separated by a space or comma"
end DO
Time = 30
!Computation
AmountR = InitialAmount*(1._wp + Rate/100._wp)**(real(Time,wp))
Write (*,210) AmountR
210 Format ("Your money has grown to:", F15.2," dollars")