language: Haskell (ghc-7.4.1)
date: 496 days 13 hours ago
link:
visibility: private
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
bmiCalculator :: IO ()
bmiCalculator = do
  putStrLn "Please input your weight"
  weight <- readLn
  putStrLn "Please input your height"
  height <- readLn
  let bmi = weight / height^2
  putStrLn $ case () of
    _ | bmi <= 17.5 -> "stuff goes here"
      | bmi <= 20.7 -> "..."
      | otherwise   -> "..."
 
{- a much better variant: extract bmi calculation into its own function -}
showBmi :: Double -> Double -> String
showBmi weight height
  | bmi <= 17.5 = "stuff goes here"
  | bmi <= 20.7 = "..."
  | otherwise   = "..."
  where bmi = weight / height^2
 
bmiCalculator :: IO ()
bmiCalculator = do
  putStrLn "Please input your weight"
  weight <- readLn
  putStrLn "Please input your height"
  height <- readLn
  putStrLn $ showBmi weight height