Question: The problem is: Write a program (in C) that prints the accumulated value of an initial investment invested at a specified annual interest and compounded

The problem is:

Write a program (in C) that prints the accumulated value of an initial investment invested at a specified annual interest and compounded annually for a specified number of years. If the accumulated amount at the start of a year is acc_amount, then at the end of one year the accumulated amount is:

acc_amount = acc_amount + acc_amount * annual_interest

Use a function that returns the accumulated value given the amount, interest (as a decimal, so 5% = 0.05), and years. The prototype is:

float calc_acc_amt(float acc_amount, float annual_interest, int years);

My professor also gives us some more information: the program should process user input until the user enters 0 for the initial amount.

This is my code so far-- right now i'm having trouble with the while loop (the loop works, but when i put in 0 for initial amount it doesn't quit & only quits after i put in zero as all my inputs). I also am not sure how to go about doing more than 1 year of compounding.

The problem is: Write a program (in C) that prints the accumulated

Thank you!

int main() // variables float acc_amount; float annual_interest; int years; float total II initial amount // annual interest rate as decimal II amount of years being compounded // total anount // prompt user for initial amount printf("Enter initial investment (0 to quit): "); scanf("%f", &acc-amount); // prompt user for annual interest rate printf("Enter annual interest rate:"; scanf("%f", &annual-interest); /I prompt user for amount of years printf("Enter number of years being compounded: "); scanf("%d", &years); while (accamount 0) II user Loop - II compute anount, call calc_acc_amt fxn total calc_acc_amt (acc_amount, annual_interest, years); printf("Enter initial investment (0 to quit): "); scanf("%f", &acc-amount ) ; printf("Enter annual interest rate:"; scanf("%f", &annual-interest); printf("Enter number of years being compounded: "); scanf("%d", &years); /I end program printf("Program ended.n") Ii calc acc amt function float calc_acc_amt(float acc_amount, float annual_interest, int years) /I variables float total; /I compute total account amount totalacc_amount acc_amount annual_interest; // total account amount // print result printf("The total account amount is %4.2f ", total); return total; 64,0-1 Bot

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!