A method that I'm working on in a C# project includes the following:
if (isDailyRateRequired)
{
CalculatedDailyRate = dailyRate;
}
if (isWeeklyRateRequired)
{
CalculatedDailyRate = weeklyRate / 7;
}
if (isMonthlyRateRequired)
{
CalculatedDailyRate = monthlyRate / 30;
}
There has to be a cleaner implementation than this. I could compress it to one line with a set of nested ternary operators, but that would be pretty much unreadable.
Other suggestions?