Server IP : 172.16.15.8 / Your IP : 3.145.75.238 Web Server : Apache System : Linux zeus.vwu.edu 4.18.0-553.27.1.el8_10.x86_64 #1 SMP Wed Nov 6 14:29:02 UTC 2024 x86_64 User : apache ( 48) PHP Version : 7.2.24 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON Directory (0705) : /home/bmmassie/ |
[ Home ] | [ C0mmand ] | [ Upload File ] |
---|
//-------------------------------------------------------------------------- // Assignment #1 - Monthly Payment of a Loan // // Written by B M Massie // September 2008 // // Purpose: To compute the monthly payment of an installment loan and // the balance remaining after half of the installments have // been made. //-------------------------------------------------------------------------- // ----------- Preprocessor Section ----------- #include <iostream> #include <iomanip> #include <cmath> using namespace std; // --------------- Main Function --------------- int main () { // ----- Variables and Constants int k, // half the number of payments NumPay; // number of monthly payments float AmtLoan, // the amount of loan IntRate, // the annual interest rate Payment, // the payment MonPay, // monthly payment Balance, // total balance Tintpay, // the total interest paid temp; // an equation 1 + (i / 12) // ----- Input Phase cout << "\n\n Welcome to the Loan Analysis Program!" << endl; cout << "\n\n Enter your loan amount --> "; cin >> AmtLoan; cout << "\n Enter your annual interest rate --------> "; cin >> IntRate; cout << "\n Enter your number of monthly payments ------> "; cin >> NumPay; // ----- Processing Phase temp = (1 + (IntRate / 12)); Payment = (pow (temp,NumPay)) / (pow (temp,NumPay) - 1) * AmtLoan * (IntRate / 12); k = (NumPay / 2); Balance = Payment * (1 - pow (temp,k - NumPay)) / (IntRate / 12); Tintpay = Payment * NumPay - AmtLoan; // ----- Output Phase cout << fixed << setprecision(2); // force fixed point format for floats cout << "\n\n~~~~~~~~~~~~~~~Loan Summary~~~~~~~~~~~~~~~~"<< endl; cout << "\n Annual Interest Rate: " << IntRate * 100; cout << "\n Number of Monthly Payments: " << NumPay << endl; cout << "\n Loan Amount: $ " << setw(10) << AmtLoan; cout << "\n Monthly payment: $ " << setw(10) << Payment; cout << "\n Balance halfway through: $ " << setw(10) << Balance; cout << "\n Total interest paid: $ " << setw(10) << Tintpay << endl; return 0; }