I need desperate help with program control. I'm okay if it's a single loop, but more than that, I"m lost!
Here's yet another problem I'm trying to work out. This program should compound the interest, but it has to do it for each of the interest rates...
Code:
#include <stdio.h>
#include <math.h>
int main()
{
int year;
double amount, principal = 1000.0, rate1 = .05, rate2 = .06,
rate3 = .07, rate4 = .08, rate5 = .09, rate6 = .10;
printf( "%ds%21s\n", "Year", "Amount on deposit" );
for ( year = 1; year <= 10; year++ ) {
amount = principal * pow( 1.0 + rate1, year );
printf( "%4d%21.2f\n", year, amount );
}
for ( year = 1; year <= 10; year++ ) {
amount = principal * pow( 1.0 + rate2, year );
printf( "%4d%21.2f\n", year, amount );
}
for ( year = 1; year <= 10; year++ ) {
amount = principal * pow( 1.0 + rate3, year );
printf( "%4d%21.2f\n", year, amount );
}
for ( year = 1; year <= 10; year++ ) {
amount = principal * pow( 1.0 + rate4, year );
printf( "%4d%21.2f\n", year, amount );
}
for ( year = 1; year <= 10; year++ ) {
amount = principal * pow( 1.0 + rate5, year );
printf( "%4d%21.2f\n", year, amount );
return 0;
}