Please help with displaying a monthly loan schedule.

I've written this program to calculate monthly payments based on the inputs below. The equation I've been given to determine monthly payments is:

monPayment = (loanAmt * monIntRate) / (1.0 -(1 + monIntRate) -noMonths

where noMonths is = 12, 24, 36, 48, and 60. noMonths is also an exponent and that is what's throwing me off.
and how do I properly assign the months 12, 24, 36, 48, and 60 to noMonths?

Any help is appreciated, thank you very much :)

1
2
3
4
5
6
7
8
9
10
11
12
13
14

monIntRate = annualIntRate / 12.0;
annualIntPercent = annualIntRate * 100.0;
loanAmt = price - downPayment - tradeIn;
noMonths = 12 && 24 && 36 && 48 && 60; (I know this is wrong, but to show what I need it to do I've written it like this)

monPayment = (loanAmt * monIntRate) / (1.0 - (1 + monIntRate)(pow -noMonths));



    cin.get();

    return 0;
} 
Last edited on

how do I properly assign the months 12, 24, 36, 48, and 60 to noMonths?

Maybe use a for loop?
1
2
3
for( int i{ 1 }; i <= 5; i++ ) {
    noMonths = i * 12;
}


Your equation doesn't match your code.

The equation I've been given to determine monthly payments is:

monPayment = (loanAmt * monIntRate) / (1.0 -(1 + monIntRate) -noMonths
 
monPayment = (loanAmt * monIntRate) / (1.0 - (1 + monIntRate)(pow -noMonths));


Also when you expand this:
1
2
3
(1.0 -(1 + monIntRate)
= 1.0 - 1 + monIntRate
= monIntRate


arrays could also help, right? its sort of better than loops they might just confuse you when trying to edit the code.

OP could use arrays to store each of the monPayments.

I don't see how for loops can confuse you, as they are meant for these kinds of scenarios.
1
2
3
4
5
for( int i{ 1 }; i <= 5; i++ ) {
    noMonths = i * 12;

    // monPayment calculation
}
It's a homework assignment , he specified all of my other variables but not noMonths, guess that I'll have to make it happen, thanks for the help guys.

And yes I cut out the majority of the code leading up to this because it works great and is irrelevant to the equation set up. Really big pain in the butt ;)
Last edited on
Topic archived. No new replies allowed.