Loan calculation formula

This is a discussion on Loan calculation formula within the C++ Programming forums, part of the General Programming Boards category; Hello all, I wrote this program to work out monthly payment for personal loan. Say, you borrow 15000 (principal) at ...

  1. #1
    Registered User
    Join Date
    Sep 2002
    Posts
    8

    Question Loan calculation formula

    Hello all,

    I wrote this program to work out monthly payment for personal loan. Say, you borrow 15000 (principal) at 7.50% APR for 4 years?
    So my formula is (maybe wrong):-
    1. months = 4 * 12;
    2. interest = principal * 7.50 / months;
    3. monthlypayment = (principal + Interest) / months;

    My monthly payment comes out as 361.38, is this correct?
    What is correct formula to do this?

    Here is my program, just in case you want to see it. Thanks.

    Code:
    // Calculating loan payment/interest
    #include <iostream>
    #include <cmath>
    #include <iomanip>
    
    using namespace std;
    
    int main()
    {
        char again;
    	
    	do
    	{
    		system("CLS");
    		
    		double amount,	//amount per month
    			principal,	//loan amount
    			rate,		//interest rate
    			interest,	//total interest
    			months,		//months
    			years,		//years term
    			totalpayment; 
    		
    		// set the floating-point number format
    		cout << setiosflags( ios::fixed | ios::showpoint )
    			 << setprecision( 2 );
    
    		cout << "Enter amount of loan: ";
    		cin >> principal;
    		cout << "Enter rate ( APR % ): ";
    		cin >> rate;
    		cout << "Enter number of years: ";
    		cin >> years;
    
    		//some calculation
    		months = years * 12;
    		interest = principal * rate / months;
    		amount = (principal + interest) / months;
    		totalpayment = principal + interest;
    
    		//display
    		cout << endl << "LOAN CALCULATION:";
    		cout << endl << "=================" << endl;
    		cout << "Total Loan      : " << setw( 8 ) << principal << endl;
    		cout << "Rate APR %      : " << setw( 8 ) << rate << endl;
    		cout << "Total years     : " << setw( 8 ) << years << endl;
    		cout << "Total interest  : " << setw( 8 ) << interest << endl;
    		cout << "Monthly payment : " << setw( 8 ) << amount << endl;
    		cout << "Total Payment   : " << setw( 8 ) << totalpayment << endl << endl;
    		cout << "Again y/n? ";
    		cin >> again;
    	} while (again == 'y' );
        return 0;
    }

  2. #2
    TransparentMember correlcj's Avatar
    Join Date
    Jun 2002
    Posts
    378

    Cool Hello!

    What is correct formula to do this?
    This might help you! When I am having problems with some of my formulas i goto ask Dr. Math . Goto google, then type in that name its a fantastic website for people like myself who are not so good with math.
    I hope this helps!
    Later.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help with calculation and loop
    By Betty in forum C Programming
    Replies: 7
    Last Post: 04-10-2006, 05:37 AM
  2. Math formula (js -->C++)
    By Demon1s in forum C++ Programming
    Replies: 20
    Last Post: 05-02-2003, 05:22 AM
  3. FORMULA for a LOAN
    By OneStiffRod in forum A Brief History of Cprogramming.com
    Replies: 3
    Last Post: 03-22-2003, 09:14 AM
  4. Formula string conversion
    By Gr3g in forum C++ Programming
    Replies: 2
    Last Post: 04-12-2002, 08:28 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21