- #1
jasonsmith206
- 10
- 0
Hello everyone, i hate that i can't figure this out and I'm just looking for good direction on how to figure out the last bit of my code. I'm first time user of C programming and haven't fully grasp the concepts and tools available to me so be patient if you offer any help. My task is to write a program that will scan a given principle which is 1000.00 for a interest rate of 2% over 20 years.
My code is this so far.
I spent a few hours getting the 0-20 year just right and the yearly compound interest is nearly complete but my assigment is to not only do the yearly but also half year, monthly, weekly and daily... this is my problem.
I've tried different ways and i keep getting random numbers that just don't work.
the other problem I'm getting is for YEARLY intererest. It won't calculate the full 20 years it does 1000 2 times for year 0 to 1 and then it compounds the interest leaving me with one year short on compound interest. this is a big assignment i know and I'm sorry for asking for help but my teacher refuses to give advice and the T.As suck really bad they have no idea what to do and i can't afford a tutor to teach me. Please teach me!
Jason
My code is this so far.
Code:
#include<stdio.h>
#include<math.h>
int main()
{
int time;
double principle, rate, amount, interest;
principle=1000;
rate=5.0; amount=principle*pow((1+rate/100),time);
printf("Year\tYearly\t Daily\n");
printf("----\t------\t ------");
for(time=1; time<=20; time++){ //yearly compound interest printf("\t\t\n%d\t%.2lf\n",time, amount);
amount=principle*pow((1+rate/100),time);
}
return 0;
}
I've tried different ways and i keep getting random numbers that just don't work.
the other problem I'm getting is for YEARLY intererest. It won't calculate the full 20 years it does 1000 2 times for year 0 to 1 and then it compounds the interest leaving me with one year short on compound interest. this is a big assignment i know and I'm sorry for asking for help but my teacher refuses to give advice and the T.As suck really bad they have no idea what to do and i can't afford a tutor to teach me. Please teach me!
Jason
Last edited by a moderator: