-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHoursCalculator.hs
29 lines (25 loc) · 1.05 KB
/
HoursCalculator.hs
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
29
-- Horas
-- Giovane Possebon
needsToWork :: Int -> Int -> Int
needsToWork hours days = hours * days
statusWork :: Int -> Int -> String
statusWork hoursWorked totalHours
| hoursWorked < totalHours = "You haven't complete your hours! "
++ show (hoursLeft hoursWorked totalHours) ++ " hours left!"
| hoursWorked == totalHours = "You have finished your hours!"
| otherwise = "You've worked more than you need to! You have "
++ show (hoursLeft hoursWorked totalHours) ++ " hours to take a break!"
hoursLeft :: Int -> Int -> Int
hoursLeft hoursWorked totalHours
| hoursWorked < totalHours = totalHours - hoursWorked
| otherwise = hoursWorked - totalHours
main = do
putStrLn "How many hours do you need to work?"
hoursDay <- readLn
putStrLn "How many work days we have in this month?"
daysMonth <- readLn
let resultTotalHours = (needsToWork hoursDay daysMonth)
putStrLn $ "You need to work " ++ show resultTotalHours ++ " hours!"
putStrLn "How many hours do you have worked already?"
hoursWorked <- readLn
print(statusWork hoursWorked resultTotalHours)