output from bank type problem
Hi everyone, I'm hoping someone might be able to help me with this problem. What i'm trying to do is get an opening balance,an annual rate of interest and a yearly withdrawal figure from the user. Then output like this:
year...balance...interest....withdrawn............ ...new balance
1 ......100..........0.5 ..............10 ............................95
2........95............0.5..............10........ ...................89.75
3........89.75.......0.5..............10.......... .................84.23
and so on... until the new balance reaches 0
and then output the amount of years it took to empty the account.
I think the problem is probably my poor understanding of loops. Any help you might have would be great!! Thankyou.
This is what i have so far.
#include <stdio.h>
int main(void)
{
float bal,rate,take;
float count,new;
printf("Enter an opening balance: ");
scanf("%f",&bal);
printf("Enter an interest rate: ");
scanf("%f",&rate);
printf("Enter an amount to be withdrawn each year: ");
scanf("%f",&take);
printf("\n\n\nyear amount interest withdrawn new balance\n\n");
bal=bal*(1+rate)-take;
new = bal;
for (count=1;count<=10;count++)
printf("%5f %10.2f %10.2f %10.2f
%10.2f\n",count,bal,rate,take,new);
}
p.s I,m new to this so i apologise if this is a mess!!