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
|
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
//**** I would like to restart the program from here if the user selects "n"
// Variable declaration
double LoanAmount, Term, YearlyInterest, Insurance, Interest, MonthlyPayment, HomeWorth, PercentTax, NumberofPayments, Rate, PropertyTax, FractionTax;
//Begin User Interface here
cout << "This program will calculate how many payments you will make on your house," << endl;
cout << "including the amount of your insurance and property tax." << endl;
cout << "How much is your loan?" << endl;
cout << "Dollars:",
cin >> LoanAmount;
cout << "Your Loan is " << LoanAmount << "$" << endl;
cout << "What is the term of the loan in years?" << endl;
cout << "Years:",
cin >> Term;
cout << "You have a " << Term << " year Loan" << endl;
cout << "What is your yearly interest rate?" << endl;
cout << "Percent:",
cin >> YearlyInterest;
cout << "You Pay " << YearlyInterest << "% Per year" << endl;
cout << "How much does your Homeowner's insurance cost per month?" << endl;
cout << "Insurance:",
cin >> Insurance;
cout << "Insurance costs " << Insurance << "$ per month" << endl;
cout << "How much is your home worth?" << endl;
cout << "Dollars:",
cin >> HomeWorth;
cout << "Your Home is worth " << HomeWorth << "$" << endl;
cout << "What percentage do you pay per year for tax?" << endl;
cout << "Percent:",
cin >> PercentTax;
cout << "Property Tax in your jurisdiction is " << PercentTax << "%" << endl;
cout << "Please review that the above information is correct, and hit y to continue, n to restart" << endl;
cout "(y/n)";
// ******* I would like to have the user press 'y' to continue or 'n' to restart back to the beginning here.
//This code meant for the calculating. I want the numbers assigned to the variables to carry over past the decision to continue and be used here.
//Begin calculations here, end user interface
FractionTax = PercentTax * .01;
Rate = (YearlyInterest / 12)* .01;
NumberofPayments = Term / 12;
PropertyTax = NumberofPayments * HomeWorth * FractionTax;
Interest = ((Rate)* pow((1 + Rate), NumberofPayments) / (pow((1 + Rate), NumberofPayments) - 1)) * LoanAmount;
MonthlyPayment = Insurance + Interest + PropertyTax;
//User Interface Display Begins
cout <<" Your Loan: "<< LoanAmount << "$"<< endl;
cout << "Term: " << Term << endl;
cout << "You will pay" << MonthlyPayment << "$ per month for" << NumberofPayments << " months" << endl;
return 0;
|