import System.IO prompt :: String -> IO String prompt text = do putStr text hFlush stdout getLine sqrtEquation :: Double -> Double -> Double -> String sqrtEquation a b c | d < 0 = "No solutions" | d == 0 = (show x1) | d > 0 = (show x1) ++ " and " ++ (show x2) where d = (b*b - 4*a*c) x1 = ((-b + sqrt(d))/2*a) x2 = ((-b - sqrt(d))/2*a) main = do a <- prompt "Input a: " b <- prompt "Input b: " c <- prompt "Input c: " let result = sqrtEquation (read a) (read b) $ read c putStrLn result