Hello - I am trying to figure out how to create a running total per year. The start total should be my previous ending year total. Can anyone help me figure out what I am doing wrong because I am clueless.
Thanks for the help
Code:
#include <stdio.h>
int main()
{
float amt = 1000;
float percent = .08;
int year = 0;
float yeartotal = 1000;
yeartotal=yeartotal+(amt*percent);
printf("Year Start End\n");
printf("----- ----- ----\n");
for(year=1; year<=10; ++year)
printf("%3d %3.0f %4.0f\n", year, amt, yeartotal*year);
return 0;
}
This is what I get when I run my code.
Code:
Year Start End
----- ----- ----
1 1000 1080
2 1000 2160
3 1000 3240
4 1000 4320
5 1000 5400
6 1000 6480
7 1000 7560
8 1000 8640
9 1000 9720
10 1000 10800
This is what it should look like.
Code:
Year Start End
----- ----- ----
1 1000.00 1080.00
2 1080.00 1166.40
3 1166.40 1259.71
4 1259.71 1360.49
5 1360.49 1469.33
6 1469.33 1586.88
7 1586.88 1713.83
8 1713.83 1850.94
9 1850.94 1999.02
10 1999.02 2158.94