Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- main = do
- putStr "Starting height (ft): "
- rawStartingHeight <- getLine
- putStr "Total air time (seconds): "
- rawAirTime <- getLine
- let startingHeight = read rawStartingHeight :: Double
- airTime = read rawAirTime :: Double
- putStrLn $ "Maximum height (ft): " ++ show (maxHeight startingHeight airTime)
- putStrLn "Another? (Y/N)"
- another <- yOrN
- if another then main else return ()
- yOrN :: IO Bool
- yOrN = do
- character <- getChar
- case character of
- 'y' -> return True
- 'Y' -> return True
- 'n' -> return False
- 'N' -> return False
- otherwise -> yOrN
- startingVelocity :: (Fractional a) => a -> a -> a
- startingVelocity startingHeight airTime = 16.087 * airTime - startingHeight / airTime
- maxHeight :: (Fractional a) => a -> a -> a
- maxHeight startingHeight airTime =
- let v = startingVelocity startingHeight airTime
- t = v / 32.174
- in (-16.087) * ((airTime / 2) ^ 2) + v * (airTime / 2) + startingHeight
Add Comment
Please, Sign In to add comment