Guest User

Untitled

a guest
Feb 21st, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. main = do
  2.     putStr "Starting height (ft): "
  3.     rawStartingHeight <- getLine
  4.     putStr "Total air time (seconds): "
  5.     rawAirTime <- getLine
  6.     let startingHeight = read rawStartingHeight :: Double
  7.         airTime = read rawAirTime :: Double
  8.     putStrLn $ "Maximum height (ft): " ++ show (maxHeight startingHeight airTime)
  9.     putStrLn "Another? (Y/N)"
  10.     another <- yOrN
  11.     if another then main else return ()
  12.  
  13. yOrN :: IO Bool
  14. yOrN = do
  15.     character <- getChar
  16.     case character of
  17.         'y' -> return True
  18.         'Y' -> return True
  19.         'n' -> return False
  20.         'N' -> return False
  21.         otherwise -> yOrN
  22.  
  23. startingVelocity :: (Fractional a) => a -> a -> a
  24. startingVelocity startingHeight airTime = 16.087 * airTime - startingHeight / airTime
  25.  
  26. maxHeight :: (Fractional a) => a -> a -> a
  27. maxHeight startingHeight airTime =
  28.     let v = startingVelocity startingHeight airTime
  29.         t = v / 32.174
  30.     in (-16.087) * ((airTime / 2) ^ 2) + v * (airTime / 2) + startingHeight
Add Comment
Please, Sign In to add comment