Anyone willing to overlook my code for mortgage formulas?
Mar 20, 2016 at 2:44pm UTC
I am extremely new, as in only doing this in
university for just a few short weeks. I found that if i am extremely literal with my variable and constants it makes it a lot easier for me.
I am doing a mortgage project in which requires user inputs and then mortgage formulations using pow function, I am stuck directly in the center of my project trying to get the correct formula for my monthly payments. Can anyone tell me what i am doing wrong or if my complete and utter OCD of my code is what is screwing me up. I will attach my entire code below.
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
#include<iostream>
#include<string>
#include<iomanip>
#include <cmath>
using namespace std;
// Constants:
const string BRDR = "$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$" ;
const int yearsOne = 15; // Loan years
const int yearsTwo = 30; // Loan Years
const int yearsThree = 40; // Loan Years
int main()
{
cout << BRDR << endl;
cout << "$" << setw(85) << "$" ;
cout << "$" << " Welcome to the mortgage information calculator 2016 $" ;
cout << "$" << setw(85) << "$" ;
cout << "$" << " Made exclusively for Dewey, Cheatum, and Howe bankers $" ;
cout << "$" << setw(85) << "$" ;
cout << "$" << " by: Carrie Mabb $" ;
cout << "$" << setw(85) << "$" ;
cout << BRDR << endl;
system("pause" );
system("cls" );
cout << "Please enter the name of the family purchasing the home: " ;
string name;
cin >> name;
cout << "Please enter the home's price: " ;
int homePrice; // Home Price
cin >> homePrice;
cout << " Please enter the down payment percentage: " ;
int dwnPayment;
cin >> dwnPayment;
cout << " Please enter the interest rate as a percentage: " ;
float interest;
cin >> interest;
system("cls" );
float monthInterest = interest/12;
int amntDown = homePrice * dwnPayment/100; // Down Payment Amount
int amntFinanced = homePrice - amntDown; // Finaced Amount
int loanMonthsFift = yearsOne * 12; // Loan term in months
int loanMonthsThirt = yearsTwo * 12;// Loan term in months
int loanMonthsFort = yearsThree * 12; // Loan term in months
int mPaymentOne = (monthInterest*(homePrice - dwnPayment))*(pow((1 + monthInterest), loanMonthsFift) / pow((1 + monthInterest), loanMonthsFift) - 1); // Montly payment for 15 years
int mPaymentTwo = (amntDown * monthInterest) / (1 - pow(1 + monthInterest, -loanMonthsThirt)); // Monthly payment for 30 years
int mPaymentThree = (homePrice * interest) / 1 - pow(1 + interest, -loanMonthsFort); // Monthy Payment for 40 years
int totalPaymentsOne = mPaymentOne * 12; // Total monthly Payments of 15 years
int totalPaymentsTwo = mPaymentTwo * 12; // Total monthly Payments for 30 years
int totalPaymentsThree = mPaymentThree * 12; // Total Montly Payments for 40 years
cout << "Financing breakdown for the " <<name << " Family: " << endl;
cout << " " << endl;
cout << " " << endl;
cout << "Price of home: $" << homePrice << endl;
cout << "Amount down: $" << amntDown << endl;
cout << "Amount financed: $" << amntFinanced<< endl;
cout << " Annual interest rate: " << interest <<"%" << endl;
cout << "Monthly interest rate: " <<interest/12 << "%" << endl;
cout << " " << endl;
cout << " " << endl;
cout << "15 year loan: " << endl;
cout << "Monthly payment: $" <<mPaymentOne<< endl;
cout << "Number of monthly payments: " << endl;
cout << "Total Payments: $" << endl;
cout << "Total interest paid on the loan: $" << endl;
cout << " " << endl;
cout << " " << endl;
cout << "30 year loan: " << endl;
cout << "Monthly payment: $" <<mPaymentTwo<< endl;
cout << "Number of monthly payments: " << endl;
cout << "Total Payments: $" << endl;
cout << "Total interest paid on the loan: $" << endl;
cout << " " << endl;
cout << " " << endl;
cout << "40 year loan: " << endl;
cout << "Monthly payment: $" << mPaymentThree<<endl;
cout << "Number of monthly payments: " << endl;
cout << "Total Payments: " << endl;
cout << "Total interest paid on the loan: $" << endl;
return 0;
}
Last edited on Mar 20, 2016 at 2:53pm UTC
Topic archived. No new replies allowed.