Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

benlangdon

macrumors 65816
Original poster
Jan 13, 2008
1,497
0
His powf() isn't wrong as far as I see, he's using floats for everything.

EDIT: Nevermind, I missed the int declaration. benlangdon - Why exactly are you using int for term1?

EDIT2: Are you sure 798.36 is the correct result? Doing the calculation on my TI-89 resulted in 8400 which is also what I get upon compiling and running your code. By the way - if you're going to input the monthly rate as a percentage as the assignment says, then you're going to need to convert it to a decimal value first. (1 + rate) is not supposed to be (1 + 7), its supposed to be (1 + 0.07). You corrected this by inputting .07 as your input in Xcode, but technically that's not correct as the assignment says to do it.

ya i changed it to int for some reason but i changed it back almost right after i posted this.

ya i worked it out to on my ti84 and got the same thing it was like 805 instead of 798
i give up i emailed my teacher with all this. i give up
 

CaptainZap

macrumors regular
Jan 17, 2007
170
0
K, I've figured it out. You need to take the rate and divide it by 1200, so since the rate is 7, we divide 7/1200 = .005833333, let this value = X for now

So we do this
(X + 1) ^ 360 = 8.1165
8.1165 * X = .047346 this is the numerator

Now for the denominator
(1 + X) ^ 360 = 8.1165
8.1165 - 1 = 7.1165

So we end up with
.047346 / 7.1165 = .006653

Then take that number and multiply it by the loan amount
.006653 * 120,000 = 798.36

Phew, that was fun.
And to fix the code, just add this line right above the calculations
Code:
		[b]rate = rate / 1200;[/b]
		rateTerm = powf(1 + rate,term1);
Except you get 3 decimal points, at least on my machine you do. But I don't know C++ so I can't fix it =D

Oh, and I used this website to find out that the rate has to be divided by 1200 http://www.1728.com/loanform.htm The equations are different but they come out the same.
 

benlangdon

macrumors 65816
Original poster
Jan 13, 2008
1,497
0
K, I've figured it out. You need to take the rate and divide it by 1200, so since the rate is 7, we divide 7/1200 = .005833333, let this value = X for now

So we do this
(X + 1) ^ 360 = 8.1165
8.1165 * X = .047346 this is the numerator

Now for the denominator
(1 + X) ^ 360 = 8.1165
8.1165 - 1 = 7.1165

So we end up with
.047346 / 7.1165 = .006653

Then take that number and multiply it by the loan amount
.006653 * 120,000 = 798.36

Phew, that was fun.
And to fix the code, just add this line right above the calculations
Code:
		[b]rate = rate / 1200;[/b]
		rateTerm = powf(1 + rate,term1);
Except you get 3 decimal points, at least on my machine you do. But I don't know C++ so I can't fix it =D

Oh, and I used this website to find out that the rate has to be divided by 1200 http://www.1728.com/loanform.htm The equations are different but they come out the same.


why are you dividing 7 by 1200?
i was thinking if seven wasn't a percent you still would * by 12 for months in a year.

edit: thanks for that site i guess i just did not know how to work the problem which is weird because she said that all the math was pretty basic as this is accounting

2nd edit
still do not understand why you divided by 1200
 

CaptainZap

macrumors regular
Jan 17, 2007
170
0
why are you dividing 7 by 1200?
i was thinking if seven wasn't a percent you still would * by 12 for months in a year.

No idea mate, that's just what http://www.1728.com/loanform.htm said :p
Wait... I think it is because if you have 7, it is a percent, so divide that by 100, you get .07, then you have to separate it into months (maybe?) and then divide by 12. Or more succinctly, 7 / 1200. But I have no idea how loans work... so...
 

benlangdon

macrumors 65816
Original poster
Jan 13, 2008
1,497
0
No idea mate, that's just what http://www.1728.com/loanform.htm said :p

i mean if it was .07% and not just 7 1200 would be like multiplying by 12 then adding 2 00's to not have a decimal so i get that but w/e

thanks

muuhhahahahaha
i got itttttttttttttttttt
it workssssssssssssssssssssss

thanks everyone.
captainzap thank you so much for helping me out with the equation and about cout after every processes worked

Sbrocket thanks for getting me started and teaching me pow

Mitthrawnuruodo thanks for clueing me in on something i missed

lazydog thanks for the info from terminal

toddburch thanks for the info

Cromulent thanks for helping me see something i missed

lee1210 thanks for helping me find my problem

Ben Langodon
Computer Science
Homework 10
4\3\08

Amount of Money Borrowed:120000
Annual Interest Rate:7
Term of Loan in years:30

Amount paid a month:798.361

now to clean it up

thank you guys so much
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.