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

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home/drsparks/project1.cpp
//--------------------------------------------------------------------------------------------------------------
// First Project for Computer Science Class
//
// Written by Dale Sparks
// September 2008
//
// Purpose:  To Calculate monthly payment for a loan, to calculate
//           balance at the halfway point of paying back your loan,
//           and the total interest paid.
//--------------------------------------------------------------------------------------------------------------


//-----Preprocessing Section-----

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

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

int main ()
 {

// -----Variables and Broken-Up Equations-----

  float
     i,                                         // annual interest rate
     pa,                                        // First Process in Calculating Payment
     pb,                                        // Second Process in Calculating Payment
     paymt,                                     // Monthly Payment
     ba,                                        // First process in calculating balance
     bb,                                        // Second process in calculating balance
     bc,                                        // Third process in calculating balance
     bal,                                       // Balance halfway through paying your loan back
     loan,                                      // Amount of loan
     ia,                                        // Interest Percentage
     ti;                                        // Total Interest paid

  int
      n;                                        // amount of the loan

//-----Input Phase-----

 cout << "Welcome to the Loan Analysis Program!!!" << endl;
 cout << "Enter Loan Amount ----------------------> ";
 cin >> loan;
 cout << "Enter Annual Interest Rate (decimal)----> ";
 cin >> i;
 cout << "Enter Number of Monthly Payments--------> ";
 cin >> n;

//-----Processing Phase-----

 pa = pow(1 + i / 12, n);
 pb = pa / (pa - 1);
 paymt = pb * loan * ( i / 12 );
 ba = n / 2;
 bb = pow( 1 + i / 12, ba - n);
 bc = (1 - bb) / (i / 12);
 bal = paymt * bc;
 ti = (n * paymt) - loan;
 ia = i * 100;

//-----Output Phase-----


   cout << fixed << setprecision(2);
   cout << "\n\n-----=====Loan Summary=====-----";
   cout << "\n\nAnnual Interest Rate:             " << ia << "%";
   cout << "\nNumber of Monthly Payments:       " << n;
   cout << "\n\nLoan Amount:                    $ " << loan;
   cout << "\nMonthly Payment:                $ " << paymt;
   cout << "\nBalance Halfway Through:        $ " << bal;
   cout << "\nTotal Interest Paid:            $ " << ti << endl;

 return 0;
}

Stv3n404 - 2023