samedi 30 janvier 2021

Nothing appears after reading user input on fortran

For some reason I don't have anything appearing after the user inputs the limits for the upper and lower limit of my table. What I want to do is make it so that if the user has an upper limit or lower limit that exceeds the bounds of -10,200 the user has to re-input the limits. If it does not exceed the limit, then it will reveal a table/matrix showing the numbers from the upper to lower limit in addition to two columns, one that converts it to Fahrenheit and another converting it to kelvin.

My do loop functions normally on its own, but after adding in the if statements nothing appears after the user inputs the upper and lower limits.. what am i doing wrong ?

program Lab03b
implicit none
integer::i,k,l
real, dimension(22)::matrix
Write (*,*) 'Please enter the upper and lower limit of your table in centigrade where the 
lower&
& and the upper limit is within -10 to 200. (separate with comma)'
Read (*,*) k,l
if (k>=abs(-10)) then
if (l<=abs(200)) then
    write (*,*) '  Centigrade', '       Farenheit', '        Kelvin'
    do i=k,l
            matrix(i)=i
            print*, i,32.0+1.8*i,i+273.15
    end do
    print*, 'your table has',k+1,'rows and 3 columns'
else 
print*, 'Your lower limit is less than -10 or your upper limit is greater than 200, please try again' 
end if
end if
  end program Lab03b

Aucun commentaire:

Enregistrer un commentaire