Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

MORTGAGE.CPP Write a program that calculates the annual after- tax cost of a new

ID: 3598769 • Letter: M

Question

MORTGAGE.CPP Write a program that calculates the annual after- tax cost of a new house for the first year of ownership. The user inputs the price of the house and the downpayment made on it. The program thus knows what the loan amount is the difference between the house price and the downpayment. The program also knows at least three constants: the loan interest rate (6%), the loan reduction cost rate (3%), and your income tax rate (35%) Home loans are subjected to an interest rate - that is one cost to home-owners. Additionally, they are paying off their loan at a certain rate (the loan reduction rate) that is another cost Thus the total annual mortgage costs for home- ownership is defined. However, home-owners get a bit of a break on their total costs because they can deduct part of their interest payments when they pay their taxes. These tax savings amount to the interest payment amount multiplied by their income tax rate So, the real annual cost to a home-owner the annual after-tax cost - is computed as the total annual mortgage cost minus the tax savings Should inputs should be of type double or int?

Explanation / Answer

#include <iostream>

using namespace std;

static double lir=0.06, lrcr=0.03, itr=0.35;

double loan_interest (int loan)

{

return double(loan)*double(lir);

}

double loan_reduction (int loan)

{

return double(loan)*double(lrcr);

}

double tax_savings(double loan)

{

return double(itr)*double(loan_interest (loan));

}

int main()

{

int price=1, dp, loan;

double mortgage, annual_cost;

while(price)

{

cout << "Enter the home price (or zero to quit):" << endl;

cin >> price;

if(price)

{

cout << "Enter the down payment:" << endl;

cin >> dp;

loan = price - dp;

mortgage = loan_reduction(loan) + loan_interest(loan);

annual_cost = mortgage - tax_savings(mortgage);

cout << "The after-tax cost is $" << annual_cost << " annually." << endl;

}

else

{

price=0;

}

}

return 0;

}