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.
#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;
}

New Topic/Question
Reply


MultiQuote





|