This commit is contained in:
Arti Zirk 2017-09-19 17:02:08 +03:00
parent f32f08335a
commit 2db2cfea06

24
prax2/calc.hs Executable file
View File

@ -0,0 +1,24 @@
#!/usr/bin/env runghc
getInt :: IO Int
getInt = do
readLn :: IO Int
main :: IO ()
main = do
putStr "Sisesta nr1: "
val1 <- getInt
putStr "Sisesta nr2: "
val2 <- getInt
putStr "Sisesta nr3: "
val3 <- getInt
putStr "Sisesta tehe (+ - * /): "
cmd <- getLine
putStr "Tulemus: "
case cmd of
"+" -> putStrLn $ (show (val1 + val2 + val3))
"-" -> putStrLn $ (show (val1 - val2 - val3))
"*" -> putStrLn $ (show (val1 * val2 * val3))
"/" -> putStrLn $ (show (fromIntegral val1 / fromIntegral val2 / fromIntegral val3))
_ -> putStrLn "Ei oska seda tehet teha!"