The daily rate is 8 times the hourly rate.
A month has 22 billable days.
Discounts are modeled as fractional numbers representing percentage, for example 25.0 (25%).
Implement a function to calculate the daily rate given an hourly rate.
Implement a function to calculate the price after a discount.
Implement a function to calculate the monthly rate, and apply a discount.
The returned monthly rate should be rounded up (take the ceiling) to the nearest integer.
Implement a function that takes a budget, an hourly rate, and a discount, and calculates how many days of work that covers.
The returned number of days should be rounded down (take the floor) to one decimal place.
https://exercism.org/tracks/elixir/exercises/freelancer-rates
defmodule FreelancerRates do
def daily_rate(hourly_rate) do
hourly_rate * 8.0
end
def apply_discount(before_discount, discount) do
before_discount - before_discount * discount * 0.01
end
def monthly_rate(hourly_rate, discount) do
ceil(daily_rate(apply_discount(hourly_rate, discount)) * 22)
end
def days_in_budget(budget, hourly_rate, discount) do
Float.floor(budget / daily_rate(apply_discount(hourly_rate, discount)), 1)
end
end