we borrowed $1000 at a 10% anual intrests rate. if we do not makre a payment for 2 years, and assuming there is no penalty for non payment, how much do we owe now?
Best Answer
simple interest:
1000 + (1000 * 0.1) * 2
compound interest:
1000 + 1000 * 0.1 + (1000 + 1000 * 0.1) * 0.1
or
1000 * (1 + 0.1) ^ 2
as function
simple interest:
function current = simple_interest(debt, rate, period)
current = debt + (debt * rate) * period;
end
compound interest:
function current = compound_interest(debt, rate, period)
Your final two fprintf()'s don't have any numerical values to be put into the %b. You need to have a variable sumOfPayments and sumOfInterest and increment that inside the loop by the payment and interest for that iteration, after you've initialized it to zero before the loop of course.
And I wouldn't use %i and %b. b is not even anything. I would use %d for integers and %.2 for fractional real numbers.
The code you've posted runs in a loop already, as long as it is nocht stopped by Ctrl-C. The loopconditionLoopRepetition==0 is alwaystrue, so pleae explain, what you want to change.
It is easier to reconsider your problem, if you post the relevant part of the code only.
Best Answer