(Financial application: compound value) Suppose you save $100 each month into a
ID: 3667040 • Letter: #
Question
(Financial application: compound value) Suppose you save $100 each month into a savings account with the annual interest rate 5%. Thus, the monthly interest rate is 0.05/12 = 0.00417. After the first month, the value in the account becomes
100 * (1 + 0.00417) = 100.417
After the second month, the value in the account becomes
(100 + 100.417) * (1 + 0.00417) = 201.252
After the third month, the value in the account becomes
(100 + 201.252) * (1 + 0.00417) = 302.507
and so on.
Write a program that prompts the user to enter a monthly saving amount and displays the account value after the sixth month. (In Exercise 5.30, you will use a loop to simplify the code and display the account value for any month.)
Sample Run: Enter the monthly saving amount: 100 (Enter)
After the sixth month, the account value is $608.81
Explanation / Answer
#include <stdio.h>
int main()
{
double Principal,After_Interest;
int i;
printf("Enter the monthly saving amount:");
scanf("%lf",&Principal);
for(i=1;i<=6;i++)
{
After_Interest = Principal*(1+0.05/12);
printf("Amount at the end of %d month is %lf ", i,After_Interest);
Principal = After_Interest + 100;
}
return 0;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.