for( interestrate=0.05; interestrate<=0.08; interestrate+=(0.01/8) )
print_results( interestrate, amount, period )
void print_results( double interestrate, double amount, double period )
{
total = calc_total( interestrate, amount, period );
month = calc_month( interestrate, amount, period );
fprintf( stdout, "total=%ld monthly=%ld for rate=%ld\n", total, month, interestrate );
}
double calc_total( double interestrate, double amount, double period )
{
return // the result of the calulation
}
double calc_month( double interestrate, double amount, double period )
{
return // the result of the calculation
}
Update:
Period might be an enum, depending on how you want to do this.
The next part is the calculation. Firstly, do they mean for the total to be a sum of the monthlies, or a single, non-compound rate? If the former, then calculating the total means adding up the monthlies, not its own function above. As for the monthlies:
Compound interest on a daily basis, would for a month mean calculating the interest for one day, adding the value onto the amount you own, and calculating the next day based on that amount, and so on, for a month. I believe that most places allow rounding to 30 days for a month, but check the requirements. Repeat for 30 iterations and you have the result. If you want just the interest earned, take out the original amount.
If compound interest is monthly, then for a month, it's just one iteration. Sometimes there's weekly, or even hourly interest periods. You'll have to format that for yourself.
Hope this helps.