Hey you programming nerds

Open to all topics
Erico
Junior Member
Posts: 1183
Joined: Sat May 30, 2009 10:49 am

Hey you programming nerds

Post by Erico »

I have to make a program in c++ where the user inputs money he has in the bank, then how many years he chooses and the interest he gets, The interest is compounded annually - so each time through a loop is another year and the interest is calculated and added to the principle for that year. what would the formula I would put in the loop be?
WORLD OF LOGS #1's

Force choking the shit out of bitches!
User avatar
Hypnos
Posts: 1452
Joined: Fri Dec 30, 2005 8:05 pm

Post by Hypnos »

Lol, I remember doing the exact thing in my programming class. Been so long since I have used any of it, no way I could do it now :P
User avatar
Moonde
Junior Member
Posts: 364
Joined: Mon Jan 02, 2006 6:36 pm

Post by Moonde »

Wouldn't it be something like this?

princ = princ + (princ * interest / 100);
Erico
Junior Member
Posts: 1183
Joined: Sat May 30, 2009 10:49 am

Post by Erico »

That doesn't add onto the previous years, im usually good at this but im juggling three projects right now and just cant wrap my head around the mathematical equation.

the interest for the next year has to account for the interest that was already added on from the previous year, for instance.

100$ to start, with 10% interest would come out to 110$ after the first year, i then need it to continue to add interest onto that for however many years the user puts in. so the second year should be 110$ * 10% = 111$ and so on and so on.

I just can't think of how to actually write that as a formula
WORLD OF LOGS #1's

Force choking the shit out of bitches!
godpigeon
Junior Member
Posts: 954
Joined: Mon Feb 04, 2008 9:57 pm

Post by godpigeon »

simply loop it how ever many years.

that's the quick and dirty answer at least.
And gone.
User avatar
ascanius
Posts: 1110
Joined: Tue Apr 04, 2006 1:56 am
Location: The Farm

Post by ascanius »

future value=principal(1+rate)^years

That's not programming, it's math.
Image
godpigeon
Junior Member
Posts: 954
Joined: Mon Feb 04, 2008 9:57 pm

Post by godpigeon »

And how do you get algorithms in programing?... It's math
And gone.
Erico
Junior Member
Posts: 1183
Joined: Sat May 30, 2009 10:49 am

Post by Erico »

ascanius wrote:future value=principal(1+rate)^years

That's not programming, it's math.
I need to figure out how to make that work in the program

That's not math, it's programming lolz :)
WORLD OF LOGS #1's

Force choking the shit out of bitches!
User avatar
ascanius
Posts: 1110
Joined: Tue Apr 04, 2006 1:56 am
Location: The Farm

Post by ascanius »

godpigeon wrote:And how do you get algorithms in programing?... It's math
Just because something is an algorithm doesn't make it math. Writing something that has a machine make a tone at a certain time is an algorithm, but I wouldn't call it math. It's just an instance of human logic being translated into mathematical logic, with the intended resolution's nature hardly being described as mathematical.

Interest compounding, on the hand, is an event that is both delineated and elucidated by mathematics. In this case, math is the intended function, and not just an intangible means to an end. Compounding is just a word used to describe variable rate exponential change, be it interest gains or inflation losses.

I wasn't trying to slight your response, just point out that he asked programmers for a math question.
Image
User avatar
Atelo
Posts: 7656
Joined: Thu Dec 29, 2005 6:47 pm

Post by Atelo »

I got the impression he was looking for the line of C++ code that would calculate it, not just the math formula.
Post Reply