Hello, I am a new to C++ student, and for class we had to write a mortgage calculating program, however, he wants us to use the amortization equation in a loop to solve for the loan amount when the payments are within $10 of 30% of monthly gross income. I have no idea how to structure the loop.
user inputs yearlyGrossIncome,and an interest rate
my program converts the yearly to monthlySalary,
the rate to a decemal then to
i = rate / m
monthlySalary = yearlyGrossIncome / 12;
m = 12
and the term t = 30 (30 years)
Ok the monthlyTargetPayment = (monthlySalary * 0.3)
and the target range is monthlyTargetSalary - 10
so anywhere between is where the monthly payment will be.
(None of this is my code by the way, just some outlines)
my program is beautiful to here.
I don't have any idea how to create a loop using the amortization equation
to find the loan amount so that the payment will end up between the target range.
so P = pricipalLoan
( m <= monthlyTargetPayment && m>=monthlyTargetPayment - 10;)
m = (P*i)/(1 - (pow((1 + i),-mt));
yes I know it needs a bit of cleaning up, but that's the gist.
How do I write a loop to drop random numbers in for P until m is within target range and then save the number as P ?
Please help
Thank you