// lab11.cpp : Defines the entry point for the console application.
//
//Adam Holthaus, steve05
#include "stdafx.h"
#include <iostream>
#include <iomanip>
#include <stdlib.h>
using namespace std;
double balance(double, double, double, double);
int _tmain(int argc, _TCHAR* argv[])
{
//Declaring variables
double monthlyrate, monthlypay, m1, m2, m3, m4, rate, oldb, newb, loan, years, numpayments, apy, month, yrs;
month = 1;
newb = 0;
//Getting loan info
cout <<"What is the value of the loan? $";
cin >> loan;
oldb = loan;
cout <<"For how long will you have the loan? ";
cin >> years;
cout <<"What percentage is your APY? ";
cin >> apy;
//Getting monthly payment
numpayments = years*12;
monthlyrate = apy/1200;
rate = monthlyrate+1;
m1 = pow(rate, numpayments);
m2 = monthlyrate*m1;
m3 = m1-1;
m4 = m2/m3;
monthlypay = m4*loan;
//Finding new balance
for(yrs = 1; yrs <= years; yrs++)
{
while(month < 12)
{
newb = balance(newb, oldb, monthlypay, rate);
month++;
}
cout <<newb <<endl;
}
return 0;
}
//newbalance.cpp calculates the new balance each month for one year, for lab11
//Adam Holthaus, steve05
#include "stdafx.h"
//Function
double balance(double newb, double oldb, double monthlypay, double rate)
{
newb = oldb + oldb*rate - monthlypay;
return newb;
}