almost complete C++ program needs math input fixing

**normally I would post this sort of thing on reddit but they seem to be down sorry! **
Worked on a project and I've fixed all the bug... or so I thought when I tried testing on ideone.com.
here is the page for reference:
http://ideone.com/ihZEp5
I'm not sure what this problem means or if I am doing the math correctly. if there is any help available I'd be most appreciative thank you!
You're doing these calculations before the user has input the data. With uninitialized garbage values, you may get unexpected results. You could declare the variables at the beginning of the program, but save the calculations until after the user has put in the real info.

Are you using ^ to indicate an exponent? ^ doesn't have that meaning in C++. There is a pow function in cmath that can be used.

1
2
3
4
	monintrate = annualintrate / 12;
	annualintpercent = annualintrate * 100;
	loanamt = price - downpayment - tradein;
	monpayment = (loanamt * monintrate) / (1.0 -(1 + monintrate) ^ -nomonths);


Last edited on
yes, thank you. I just tried what you said and placed the solutions just short of the output results in the end commands. do I make a space as in *pow (-nomonths) * or do I do it like this pow(-nomonths))

here is what I tried:

monintrate = annualintrate / 12;
annualintpercent = annualintrate * 100;
loanamt = price - downpayment - tradein;
monpayment = (loanamt * monintrate) / (1.0 - (1 + monintrate) pow(-nomonths));
It seems to tell me: syntax error : missing ';' before identifier 'pow' *** and ")" missing
Last edited on
There's more info on how to use pow here - it takes two arguments for the base and exponent.

http://www.cplusplus.com/reference/cmath/pow/
Oh thank you, I read that like twice before and kept messing up. I just figured out what it's doing. thank you sir! You've been a great help! :)
I'm not a sir, but you're welcome :)



Topic archived. No new replies allowed.