Add calc
This commit is contained in:
parent
f32f08335a
commit
2db2cfea06
24
prax2/calc.hs
Executable file
24
prax2/calc.hs
Executable 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!"
|
Loading…
Reference in New Issue
Block a user