Last active
May 4, 2016 18:03
-
-
Save thejsj/a64e2ec994b5603c62f137e30d0e4240 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Data.List.Split | |
import Data.Char | |
import Data.Maybe | |
import Text.Read | |
converToFloat :: String -> Maybe Float | |
converToFloat x = readMaybe x :: Maybe Float | |
convertStringsToFloats :: [String] -> [Float] | |
convertStringsToFloats x = map fromJust $ filter (not . null) $ map converToFloat x | |
splitIntoNumbers :: String -> [Float] | |
splitIntoNumbers x = convertStringsToFloats $ splitOn "," x | |
assignBonus :: Float -> Float | |
assignBonus x | |
| x <= 10000.0 = x * 0.03 | |
| x <= 15000.0 = x * 0.06 | |
| x <= 25000.0 = x * 0.09 | |
| otherwise = x * 0.15 | |
getBonusesForEmployess = (map assignBonus) . splitIntoNumbers | |
main = do | |
print "Sales?:" | |
input <- getLine | |
print "Result:" | |
print $ getBonusesForEmployess input |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment