this is an assignment I'm working on, and it is unfinished...so i'm stuck ... can you guys help please?

i wrote something likeCode:Write a C program that calculates the final value of an investment made in a TSX Market Linked GIC. Specification The return on this type of GIC (Guaranteed Investment Certificate) is based on the initial investment, the number of years (1, 2 or 3), a minimum return rate, a maximum return rate, a participation rate, the values of the TSX (Toronto Stock Exchange) index at specified intervals during the years, and the type of averaging of these values. The final investment value can only be calculated once all the TSX values are known. If averaging is not used the TSX rate is determined from the opening and closing values only. If averaging is used the TSX rate is determined by calculating the TSX average at 6 monthly intervals, then is based on this average relative to the opening value. The TSX rate is then multiplied by the participation rate. If this new rate is below the minimum rate, then the minimum rate is used, and if it is above the maximum rate, then the maximum rate is used. Rates are printed to 2 decimal places, and the final investment is rounded down, and formatted using commas. Only round down for the final investment. If the TSX rate is negative do not print the line for rate adjusted for participation. Assume that the final investment is less than one million dollars. (Hint: if you need to print leading zeros in a number, use the %0m.n format: example – the format specifier %06.2f prints 4.56 as 004.56) Example 1: See below; averaging is not used, so TSX rate = (107-100)/100 = 7%. After using a participation rate of 80%, get 5.6% (which is between min & max rates). Example 2: See below; averaging is used over 5 values to get a rate of 68% which equals 54.4% due to participation. This is more than the max rate, so the max rate is used. The GIC calculator must use the following layout exactly. +------------------------------------+ | TSX MARKET LINKED GIC CALCULATOR | +------------------------------------+ Enter initial investment : 1000.00 Enter number of years [1,2,3] : 3 Enter minimum and maximum rates [%] : 1 20 Enter participation rate [%] : 80 Enter if averaging used [1=yes,0=no]: 0 Enter open and close values : 100 107 TSX rate . . . . . . . . . . . . . . 7.00% Rate adjusted for participation . . 5.60% Final investment . . . . . . . . . . $ 1,056.00 +------------------------------------+ | TSX MARKET LINKED GIC CALCULATOR | +------------------------------------+ Enter initial investment : 2000.00 Enter number of years [1,2,3] : 2 Enter minimum and maximum rates [%] : 1 20 Enter participation rate [%] : 80 Enter if averaging used [1=yes,0=no]: 1 Enter 5 TSX values : 200 190 320 430 540 TSX rate . . . . . . . . . . . . . . 68.00% Rate adjusted for participation . . 54.40% Maximum rate is applicable . . . . . 20.00% Final investment . . . . . . . . . . $ 2,040.00

Code:#include <stdio.h> int main (void) { int years, minimum, maximum, partrate, x, open, close, tsxvalue; float investment, tsxrate, y, finalinvestment, maxrate, minrate; printf("+------------------------------------+\n"); printf("| TSX MARKET LINKED GIC CALCULATOR |\n"); printf("+------------------------------------+\n"); printf("Enter initial investment : "); scanf("%.21f", &investment); printf("\n"); printf("Enter number of years [1,2,3] : "); scanf("%d", &years); printf("\n"); printf("Enter minimum and maximum rates [%] : "); scanf("%d %d", &minimum, &maximum); printf("\n"); printf("Enter participation rate [%] : "); scanf("%d", &partrate); printf("\n"); printf("Enter if averaging used [1=yes,0=no]: "); scanf("%d", &x); printf("\n"); if (x=0) { printf("Enter open and close values : "); scanf("%d %d", &open, &close); printf("\n"); printf("\n"); tsxrate = (close - open)/100; printf("TSX rate . . . . . . . . . . . . . . %.21f", tsxrate); printf("\n"); y = tsxrate * ((float)partrate/100); printf("Rate adjusted for participation . . %.21f", y); printf("\n"); printf("\n"); finalinvestment = (y * 100) + investment; printf("Final investment . . . . . . . . . . $%.21f", finalinvestment); } if (x=1) { printf("Enter 5 TSX values : "); scanf("%d %d %d %d %d", tsxvalue, tsxvalue, tsxvalue, tsxvalue, tsxvalue); printf("\n"); // i don't know what the exact calculation should be here now to get the rest....so I'm stuck here