Skip to content

Instantly share code, notes, and snippets.

@bbhoss
Created March 20, 2012 21:26
Show Gist options
  • Select an option

  • Save bbhoss/2141454 to your computer and use it in GitHub Desktop.

Select an option

Save bbhoss/2141454 to your computer and use it in GitHub Desktop.
calcBMI :: Float -> Float -> Float
calcBMI heightIn weightLbs = (weightLbs*703)/heightIn^2
promptFloat :: String -> IO Float
promptFloat question = do
putStrLn question
return =<< readLn
main = do
weight <- promptFloat "What is your weight in pounds?"
height <- promptFloat "What is your height in inches?"
putStrLn ("Your weight is " ++ show weight ++ "lbs. and your height is " ++ show height ++ "in.")
putStrLn $ "Your BMI is " ++ (show $ calcBMI height weight)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment