1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264
|
// finalproject.cpp : main project file.
#include"stdafx.h"
#include<iostream>
#include <string>
using namespace System;
using namespace std ;
int main()
{
// prototype of variables
string $firstname ;
char $pmiresponse ;
int $yearsleft = 0 ;
int $monthsleft = 0 ;
char $changeoption ;
int $currenthomevalue = 0 ;
int $mortgageterminyears = 0 ;
int $newmortgageterminyears = 0 ;
float $totalinterest = 0.0f ;
float $monthlypayment = 0.0f ;
float $principleamount = 0.0f ;
float $newinterestrate = 0.0f ;
float $pmipaymentamount = 0.0f ;
float $extrapaymentamount = 0.0f ;
float $currentinterestrate = 0.0f ;
float $currentpaymentamount = 0.0f ;
// prototype of functions
int $testfunc1 = 0 ;
int $testfunc2 = 0 ;
int _testfunc(int $testfunc1,int $testfunc2) ;
{
$currentpaymentamount = $testfunc1 + $testfunc2 ;
return($currentpaymentamount) ;
}
float _calculatecurrentmortgage(float $calculatecurrentmortgagevar1, float $calculatecurrentmortgagevar2) ; // , int $calculatecurrentmortgagevar3, int $calculatecurrentmortgagevar4) ;
// $monthlypaymentnumerator = principle (interestrate) * ((1 + interestrate) * numberofmonths)
// $monthlypaymentdenominator = ((1 + interestrate) * numberofmonths) - 1
// float variable 1 is the principle amount $principleamount
// float variable 2 is the current interest rate $currentinterestrate
// int variable 3 is the loan term in years $mortgageterminyears
// int variable 4 is unused currently
float $calculatecurrentmortgagevar1 = 0 ;
float $calculatecurrentmortgagevar2 = 0 ;
float $calculatecurrentmortgagevar3 = 0 ;
float $calculatecurrentmortgagevar4 = 0 ;
float _calculatetotalinterest(float $calculatetotalinterestvar1, float $calculatetotalinterestvar2) ; // , int $calculatetotalinterestvar3, int $calculatetotalinterestvar4) ; // has to bring in these 4 variables, all are option, and need to have defaults if they aren't passed
// $totalinterest = ($currentpaymentamount * ($mortgageterminyears * 12)) - $principleamount
// float variable 1 is the principle amount $principleamount
// float variable 2 is the current interest rate $currentinterestrate
// int variable 3 is the loan term in years $mortgageterminyears
// int variable 4 is unused currently
float $calculatetotalinterestvar1 = 0 ;
float $calculatetotalinterestvar2 = 0 ;
float $calculatetotalinterestvar3 = 0 ;
float $calculatetotalinterestvar4 = 0 ;
cout << "Welcome ... [program introduction text removed to be within forum character limit] ... payment." << endl ;
cout << endl ;
cout << "Hello, what is your first name?" << endl ; // first name entry
cin >> $firstname ;
cout << $firstname << endl ;
cout << "Thank you " << $firstname << ", now onto the calculations part of this program. Let’s start with your current mortgage, how many years was your mortgage for, originally?" << endl ; // original term of mortgage entry
cin >> $mortgageterminyears ;
cout << $mortgageterminyears << endl ;
cout << "How many years do you have left on your current mortgage?" << endl ; // years left on mortgage entry
cin >> $yearsleft ;
cout << $yearsleft << endl ;
cout << "How many months left?" << endl ; // months left on mortgage entry
cin >> $monthsleft ;
cout << $monthsleft << endl ;
cout << "How much money did you borrow from the bank? (this is also known as your principle)" << endl ; // principle loan amount entry
cin >> $principleamount ;
cout << $principleamount << endl ;
cout << "What is your current fixed interest rate?" << endl ; // current interest rate entry
cin >> $currentinterestrate ;
cout << $currentinterestrate << endl ;
cout << "What is your homes current value?" << endl ; // current value of home entry
cin >> $currenthomevalue ;
cout << $currenthomevalue << endl ;
_testfunc($currenthomevalue, $yearsleft) ; // , $currenthomevalue, $currenthomevalue) ;
cout << "Thanks. Your principle + interest payment is " << $currentpaymentamount << " per month. You will pay " << $totalinterest << " over the life of the loan. Do you currently pay private mortgage insurance?" << endl ; // current payment output and pmi question is answered
cin >> $pmiresponse ;
if ($pmiresponse = 'Y')
{
cout << "How much is your private mortgage insurance per month?" << endl ;
cin >> $pmipaymentamount ;
}
else
{
$pmipaymentamount = 0 ;
}
cout << $pmipaymentamount << endl ;
restart:
cout << "Now what would you like to change? Press 1 for your monthly payment amount. Press 2 for the term (length) of the loan. Press 3 for the interest rate. Press ‘r’ to restart and ‘x’ to quit." << endl ;
cin >> $changeoption ;
cout << $changeoption << endl ;
switch ($changeoption)
{
case 1:
cout << "How much extra would you like to pay in addition to the " << $currentpaymentamount << " that you pay each month?" << endl ;
cin >> $extrapaymentamount ;
// _recalculate($extrapaymentamount + $currentpaymentamount, , ) ;
break;
case 2:
cout << "How many years would you like the term of your loan to be for?" << endl ;
cin >> $newmortgageterminyears ;
// _recalculate(,$newmortgageterminyears,) ;
break;
case 3:
cout << "What would you like your new interest rate to be calculated at?" << endl ;
cin >> $newinterestrate ;
// _recalculate(,,$newinterestrate) ;
break;
case 4:
cout << "Starting calculations over." << endl ;
// cin >> ;
goto restart ;
break;
default :
cout << "Thank you for using this tool." << endl ;
// cin >> ;
return(0) ;
break;
}
float _calculatecurrentmortgage(float $calculatecurrentmortgagevar1, float $calculatecurrentmortgagevar2) ; // , int $calculatecurrentmortgagevar3, int $calculatecurrentmortgagevar4) ; // has to bring in these 4 variables, all are option, and need to have defaults if they aren't passed
// variable 1 is the principle amount $principleamount
// variable 2 is the current interest rate $currentinterestrate
// variable 3 is the loan term in years $mortgageterminyears
//M = P [ i(1 + i)n ] / [ (1 + i)n - 1
{
// $monthlypaymentnumerator = principle (interestrate) * ((1 + interestrate) * numberofmonths)
// $monthlypaymentdenominator = ((1 + interestrate) * numberofmonths) - 1
// $monthlypaymentnumerator = $principleamount ($currentinterestrate / 12) * ((1 + ($currentinterestrate / 12)) * ($mortgageterminyears *12))
// $monthlypaymentdemoninator = ((1 + ($currentinterestrate/12)) * ($mortgageterminyears * 12)) - 1
// $currentpaymentamount = $monthlypaymentnumerator/$monthlypaymentdenominator
$currentpaymentamount = $calculatecurrentmortgagevar1 + $calculatecurrentmortgagevar2 ;
// has to return $currentpaymentamount to the rest of the program
// QUESTIONS
// Do I have to delcare the variables local or global?
// What happens if I pass a int value to a float variable?
return($currentpaymentamount) ;
}
float _calculatetotalinterest(float $calculatetotalinterest1, float $calculatetotalinterest2) ; // , int $calculatetotalinterest3, int $calculatetotalinterest4) ;
{
// variable 1 is the principle amount $principleamount
// variable 2 is the current interest rate $currentinterestrate
// variable 3 is the loan term in years $mortgageterminyears
// $totalinterest = ($currentpaymentamount * ($mortgageterminyears * 12)) - $principleamount
// has to return $totalinterest to the rest of the program
$totalinterest = 5.5 ;
return($totalinterest) ;
}
system("PAUSE") ;
}
|