Hello again people, I've been trying to get my floats converted to integers, but I have a feeling that I am not supposed to be using something like static_cast to do so, so I have no idea where I should start looking as I've only been staring foolishly at my monitor hoping my second brain cell wakes up.
code currently looks like this:
#include <cmath>
// daily_rate calculates the daily rate given an hourly rate
double daily_rate(double hourly_rate) {
return hourly_rate * 8.0;
}
// apply_discount calculates the price after a discount
double apply_discount(double before_discount, double discount) {
return before_discount * (discount * 0.01);
}
// monthly_rate calculates the monthly rate, given an hourly rate and a discount
// The returned monthly rate is rounded up to the nearest integer.
int monthly_rate(double hourly_rate, double discount) {
const double month_billable_days{22};
return round(
apply_discount(daily_rate(hourly_rate)* month_billable_days, discount)
);
}
// days_in_budget calculates the number of workdays given a budget, hourly rate,
// and discount The returned number of days is rounded down (take the floor) to
// the next integer.
double days_in_budget(int budget, double hourly_rate, double discount) {
// TODO: Implement a function that takes a budget, an hourly rate, and a
// discount, and calculates how many complete days of work that covers.
const double daily_rate_discounted{
apply_discount(daily_rate(hourly_rate), discount)
};
const int budget_remainder{budget % static_cast<int>(daily_rate_discounted)};
return floor(
(budget - budget_remainder) / daily_rate_discounted
);
}
error:
make[2]: *** [CMakeFiles/test_freelancer-rates.dir/build.make:70: CMakeFiles/test_freelancer-rates] Arithmetic exception (core dumped)
make[1]: *** [CMakeFiles/Makefile2:111: CMakeFiles/test_freelancer-rates.dir/all] Error 2
make: *** [Makefile:91: all] Error 2