In this exercise you'll be writing code to help a freelancer communicate with a project manager by providing a few utilities to quickly calculate daily and monthly rates, optionally with a given discount.
We first establish a few rules between the freelancer and the project manager:
Sometimes, the freelancer is offering to apply a discount on their daily rate (for example for their most loyal customers or for non-for-profit customers).
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:
FreelancerRates.daily_rate(60)
# => 480.0The returned daily rate should be a float.
Implement a function to calculate the price after a discount.
FreelancerRates.apply_discount(150, 10)
# => 135.0The returned value should always be a float, not rounded in any way.
Implement a function to calculate the monthly rate, and apply a discount:
FreelancerRates.monthly_rate(77, 10.5)
# => 12130The 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.
FreelancerRates.days_in_budget(20000, 80, 11.0)
# => 35.1The returned number of days should be rounded down (take the floor) to one decimal place.
In this exercise you'll be writing code to help a freelancer communicate with a project manager by providing a few utilities to quickly calculate daily and monthly rates, optionally with a given discount.
We first establish a few rules between the freelancer and the project manager:
Sometimes, the freelancer is offering to apply a discount on their daily rate (for example for their most loyal customers or for non-for-profit customers).
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:
FreelancerRates.daily_rate(60)
# => 480.0The returned daily rate should be a float.
Implement a function to calculate the price after a discount.
FreelancerRates.apply_discount(150, 10)
# => 135.0The returned value should always be a float, not rounded in any way.
Implement a function to calculate the monthly rate, and apply a discount:
FreelancerRates.monthly_rate(77, 10.5)
# => 12130The 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.
FreelancerRates.days_in_budget(20000, 80, 11.0)
# => 35.1The returned number of days should be rounded down (take the floor) to one decimal place.