1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
#include <iostream> #include <cmath> #include<iomanip> using namespace std; int main() { double loanAmount; int numberOfYears; double annualInterestRate = 5; double monthlyInterestRate; double monthlyPayment; double totalPayment; // Enter loan amount cout << "Loan Amount: "; cin >> loanAmount; // Enter number of years cout << "Number of Years: "; cin >> numberOfYears; // Obtain monthly interest rate monthlyInterestRate = annualInterestRate / 12; for (double i = 5; i <= 8; i += 0.125) // i has to be a float { for(double j = 1; j <= numberOfYears;j++) { monthlyPayment = monthlyPayment = loanAmount * monthlyInterestRate / (1 - 1 / pow(1 + monthlyInterestRate, numberOfYears * 12)); cout << setw(3) << j; cout << "\n"; } } for (double x = numberOfYears; x < totalPayment; x++ ) { totalPayment = monthlyPayment * numberOfYears * 12; cout << setw(3) << x; cout << "\n"; } // Display results cout << "Interest Rate " << annualInterestRate << "% " << "\nMonthly Payment " << monthlyPayment << "\nTotal Payment " << totalPayment << endl; return 0; }