! Figure 4.8
   program temp_convert
   !   Print a conversion table of the Fahrenheit and Celsius
   !   temperature scales between specified limits.
   !
      real :: celsius, fahrenheit
      integer :: low_temp, high_temp, temperature
      character(len=1) :: temp_scale
   !
   read_loop:   do
   !
   !   Read scale and limits
         read *, temp_scale, low_temp, high_temp
   !
   !   Check for valid data
         if (temp_scale /= "C" .and. temp_scale /= "F") then
            exit read_loop
         end if
   !
   !   Loop over the limits
         do  temperature = low_temp, high_temp
   !
   !   Choose conversion formula
            select case (temp_scale)
            case ("C")
               celsius = temperature
               fahrenheit = 9.0/5.0*celsius + 32.0
            case ("F")
               fahrenheit = temperature
               celsius = 5.0/9.0*(fahrenheit-32.0)
            end select
   !
   !   Print table
            print *, celsius, " degrees C correspond to",  &
                   fahrenheit, " degrees F"
         end do
      end do read_loop
   !
   !   Termination
      print *, " End of valid data"
   end program temp_convert
