Jump to content

Hi i am new to C++  and have attempted this problem a couple of time and just cant seem to get it it correct can anyone help me wiht this?

Exercise #5 – Loan Problem
The monthly payment on a loan may be calculated by the following formula:
Payment= (  Rate∗(1+Rate)^N / ((1+Rate)N−1)  )∗L

Rate is the monthly interest rate, which is the annual interest rate divided by 12 (12% annual interest
would be 1 percent monthly interest.) N is the number of payments and L is the amount of the loan.
Write a program that asks for these values and displays a report similar to:
Loan Amount: $ 10000.00
Monthly Interest Rate: 1%
Number of Payments: 36
Monthly Payment: $ 332.14
Amount Paid Back: $ 11957.15
Interest Paid: $ 1957.15

Link to comment
https://linustechtips.com/topic/304869-need-help-with-c-school-prblem/
Share on other sites

Link to post
Share on other sites

Ok so first of all I am NOT AN EXPERT at c++ I am just starting as well. The formula provided didn't work for me but I made one that I think, "THINK", calculates interest correctly or at least as described. I could be VERY wrong and if I am I'm sure someone will point that out. Anyway here's what I got to work.

#include <iostream>using namespace std;void CalcLoan(float Loan,float Rate,float NumPayments){    float MonthlyAmount,TotalPaid,InterestPaid;    MonthlyAmount=(Loan * (Rate + 100)/100) / NumPayments;    TotalPaid = MonthlyAmount * NumPayments;    InterestPaid = TotalPaid - Loan;    cout << "Loan Amount: $" << Loan << endl    << "Monthly interest rate :" << Rate << "%" << endl    << "Number of payments :" << NumPayments << endl    << "Monthly payments :" << MonthlyAmount << endl    << "Amount paid back :" << TotalPaid << endl    << "Interest paid :" << InterestPaid << endl;}int main(){    float LoanAmount,Rate,NumPayments;    cout << "Hello! How much would you like to borrow : $";    cin >> LoanAmount;    cout << "Now input an annual interest rate: ";    cin >> Rate;    cout << "Ok and how many payments will you be breaking that into? : ";    cin >> NumPayments;    CalcLoan(LoanAmount,Rate/12,NumPayments);    return 0;} 
Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×