1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
|
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
void Read_Loan_Info(float Principal, float Rate, int Years, int PaymentsPerYear);
float MonthlyPayment(float Principal, float Rate, int Years, int PaymentsPerYear);
void Show_Table(float Principal, float Rate, int Years, int PaymentsPerYear);
int main ()
{
int Years, PaymentsPerYear;
float Rate, Principal;
char Again = 'Y';
if (Again == 'Y' || Again == 'y')
{
cout << "Enter the Principal --> ";
cin >> Principal;
cout << "\nEnter the Interst Rate --> ";
cin >> Rate;
cout << "\nEnter the Years --> ";
cin >> Years;
cout << "\nEnter the Period --> ";
cin >> PaymentsPerYear;
Read_Loan_Info( Principal, Rate, Years, PaymentsPerYear);
MonthlyPayment( Principal, Rate, Years, PaymentsPerYear);
Show_Table( Principal, Rate, Years, PaymentsPerYear);
cout << "\nWould you like use again? Y or N?";
cin >> Again;
}
}
void Read_Loan_Info(float Principal, float Rate, int Years, int PaymentsPerYear)
{
}
float MonthlyPayment(float Principal, float Rate, int Years, int PaymentsPerYear)
{
int Term;
float Interest_Rate, MonthPayment;
Interest_Rate = Rate / 12;
Term = Years * PaymentsPerYear;
MonthPayment = Principal * (Interest_Rate / (1 - pow(Interest_Rate + 1,-Term)));
return MonthPayment;
}
void Show_Table(float Principal, float Rate, int Years, int PaymentsPerYear)
{
int TotalPayments;
TotalPayments = Years * PaymentsPerYear;
cout << "\nPrincipal " << Principal;
cout << "\nInterest Rate " << Rate;
cout << "\nNo. of Years " << Years;
cout << "\nPayments per year " << PaymentsPerYear;
cout << "\nNo. of Payments " << TotalPayments;
cout << "\nMonthly Payment " << MonthlyPayment( Principal, Rate, Years, PaymentsPerYear);
}
|