All pastes #354172 Raw Edit

Anonymous

public text v1 · immutable
·published 2007-02-13 20:20 UTC
rendered paste body
// program to calculate the monthly payment on a loan.
// The formula is Payment = Rate * (1 + rate)^N / ((1+Rate)^N -1) * L
// Rate is the monthly interest rate, which is the annual interest rate / 12
// N is the number of payments and L is the amount of th loan.
// The following program will ask for the values of Rate, Interest, Amount of Loan, and number of payments.


#include <iostream>
#include <iomanip>
#include <cmath>


int main()
{
	double loan, rate, payment, numpay;
	
	
	
	std::cout << "This is a program to calculate the monthly payment on a loan\n";
	std::cout << "for a given amount of interest, and number of payments.\n\n" << std::endl;
	
		std::cout << "Enter the amount of the loan: ";
			std::cin >> loan;
		std::cout << "Enter the annual rate ofrate of interest: ";
			std::cin >> rate;
		std::cout << "Enter the number of paymenths: ";
			std::cin >> numpay;

					
		payment = (rate * pow( 1+rate, numpay)) / ((pow(1+rate, numpay)) -1 * loan);
		
		std::cout << "Press any key to continue." << std::endl;
			std::cout << "Loan Amount: " << loan << std::endl;
			std::cout << "Monthly Interest rate: " << (rate / 12) << std::endl;
			std::cout << "Number of Payments: " << numpay << std::endl;
			std::cout << "Monthly Payments: " <<  payment << std::endl;
			
	
	return 0;

}