Kanjut SHELL
Server IP : 172.16.15.8  /  Your IP : 3.139.108.48
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/cchansen/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home/cchansen/payment1.cpp
// ---------------------------------------------------------------------------
//  Program #1 - Loan Summary and Analysis
//
//  Written by Caitlin Hansen
//  September 2008
//
//  Purpose: To compute the monthly payment of an installment loan, the 
//  balance remaining after half of the installments have been made, and the
//  total amount of interest paid over the life of the loan.
// ----------------------------------------------------------------------------

// ---------- Preprocessor Section ----------

#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;

// -------------- Main Function --------------

int main ()
{

// ------Variables and Constants

  const int
     MTHPYMT = 12;   // the twelve monthly payments required by the loan

  int
     totalmth,       // the number of monthly payments 
     mthhalf;        // the number of months half way through installments
     
  float
     loanamt,        // the amount the loan was made for 
     intrate,        // the annual interest rate of the loan
     pymtamt,        // the amount of each payment made
     balance,        // the balance half way through installments
     totalint;       // the total interest paid

// ------ Input Phase

  cout << endl;
  cout << "   Welcome to the Loan Analysis Program! ";
  cout << endl;
  cout << endl;
  cout << "       Enter loan amount --------------------------> ";
  cin >> loanamt;
  cout << endl;
  cout << "       Enter annual interest rate (as a decimal) --> "; 
  cin >> intrate;
  cout << endl;
  cout << "       Enter number of monthly payments -----------> ";
  cin >> totalmth;
  cout << endl;
  cout << endl;

// ------ Processing Phase

  pymtamt = (pow(1 + (intrate / 12),totalmth) / (pow(1 + (intrate / 12),totalmth)- 1)) * loanamt * (intrate / 12);

  mthhalf = totalmth / 2;

  balance = pymtamt * ((1 - (pow(1 + (intrate / 12),(mthhalf - totalmth))))) / (intrate / 12);

  totalint = (pymtamt * totalmth) - loanamt;

// ------ Output Phase

  cout << fixed;   // force fixed point format for floats

  cout << "        *~~~~~~~~~~~~~~~*~~~~~~~~~~~~~~~*~~~~~~~~~~~~~~~*";
  cout << endl;
  cout << "        *~~~~~~~~~~~~~~~~~~~Loan Summary~~~~~~~~~~~~~~~~*";
  cout << endl;
  cout << "        *~~~~~~~~~~~~~~~*~~~~~~~~~~~~~~~*~~~~~~~~~~~~~~~*";
  cout << endl;
  cout << endl;
  cout << setprecision(2);   // two decimal digit for floats
  cout << "           Annual Interest Rate: % " << intrate * 100;
  cout << endl;
  cout << "           Number of Monthly Payments: " << totalmth;
  cout << endl;
  cout << endl;
  cout << "             Loan Amount:              $ " << setw(10) << loanamt;
  cout << endl;
  cout << "             Monthly Payment:          $ " << setw(10) << pymtamt;
  cout << endl;
  cout << "             Balance halfway through:  $ " << setw(10) << balance;
  cout << endl;
  cout << "             Total Interest Paid:      $ " << setw(10) << totalint;
  cout << endl;

return 0;
}

Stv3n404 - 2023