Little practice work from class, Confused

You have been hired by Home Loans Made Easy Bank, which services Mecklenburg and Cabarrus counties. Your first programming task is to create a program to determine whether or not an applicant qualifies to receive a home loan based on his/her ability to repay a mortgage. This bank only writes mortgages for a term of 20 years. Cabarrus County reduces its tax rate by .002 for senior citizens (age 65 or older) and for active military applicants.
Consider the following:

Purchase Price – how much does the desired house cost
Down Payment – how much will the applicant pay up front (amount not to be financed)
If applicant puts down less than 20% of the cost of the home, (s)he must also pay private mortgage insurance each month at the rate of 1% of loan amount.

Principal – amount of loan needed
Interest Rate – 5%
Taxes – annual property tax for house according to county (Mecklenburg – 0.015, Cabarrus – 0.012)
Insurance – cost of homeowner’s insurance is at the rate of $250 per $50,000, or fraction thereof, cost of house. (example: insurance for a $125,000 house is $750).

Annual Income – how much money does the applicant earn in a year (gross figure, not net)
Monthly Existing Debt – how much does the borrow already pay each month for other debt
Debt-to-Income-Ratio – how much of the applicant’s monthly income can be used for debt. This should include current monthly debt payments plus mortgage payment. NOTE: this is a constant amount of 28%

The applicant will qualify for the mortgage if his/her debt-to-income ratio is at or below 28%.

Your program must tell the applicant
Whether or not (s)he qualifies
His/her debt-to-income ratio

I have come to a stump, I just don't know what else to do, I am a beginner to C++ and this is an extra credit assignment that I'd thought I would do since Im new to programming and my overall grade wont be that high.
Any Help on where I can start next would be greatly appreciated.

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
#include <iostream>

using namespace std;

// Here are some Formula's for calculating compound interest on a mortgage loan
//Note: ^ means power, therefore P(1+r) is raised to the power of n (number of years for loan)
//A=P(1+r)^n
//A - total cost of mortgage plus interest
//P – principal
//r – interest rate
//n – number of years


//My job is to Your first programming task is to create a program to determine
//whether or not an applicant qualifies to receive a home loan based on his/her ability to repay a mortgage.
int main()
{
// Declare Variables
    double purchasePrice;
    double downPayment;
    double principal;
    double interestRate;
    double insuranceRate; //cost of homeowners insurance is at the rate of $250 per $50,000, 750 = 125000
    double annualIncome;
    double monthlyDebt;
    const double meckTax = .015;
    const double cabTax = .012;
    const double debtincomeRatio = .28;  //28% constant rate
    const double seniortaxDiscount = .002; // 65 or older and military
    char response;

// Ask for Inputs

    cout << "How much does the house cost?" << endl;
    cin >> purchasePrice;

    cout << "How much will the applicant pay up front?" << endl;
    cin >> downPayment;

    cout << "Is the down payment less then 20 percent?(Y/N)" << endl;
    cin >> response;
    if (response == 'Y' )
    {

    }
    else if (response == 'N')
    {f
    }

    cout << "How much of a loan do you need?" << endl;
    cin >> principal;

    cout << "" << endl;
    cin >> ;
// Calculations

 = principal(1+interestRate)^

// Ask for Outputs

    cout << "Did you qualify for the home loan?" <<  <<  endl; //add variable
    cout << "You can use this amount of money for debt from your monthly income:" <<  <<  endl;  //add a variable
    
    return 0;
}
You're given all the instructions you need. You just need to work through them.

Lines 40-48: Why are you asking the user if the down payment is less than 20%. You should be calculating that. interestRate is uninitialized. You're given a base interest rate of 5%. You need to adjust that if the down payment is less than 20%.

1
2
3
4
5
6
7
8
   double down_pmt_pct;
   double interestRate = 0.05;

  down_pmt_pct = 1 - (downPayment / purchasePrice);
  if (down_pmt_pct < 0.20) 
  { cout << "This loan requires mortgage insurance at 1%" << endl;
     interestRate += 0.01;
  }


Line 50, again, you're asking a question you should be calculating. principal is purchase price - down payment.

Lines 54 - 57: This lines are incomplete.

Follow the instructions. Ask the user for the remaining information you need (annual income, monthly debts). Compute what you can, compute the debt ratio and decide if it greater than 28%.
Thanks for the feedback! I took a look at your helpful information and this is what I got so far, All i need now is some more calculations and outputs correct?
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
#include <iostream>
#include <cmath>
#include <iomanip>

using namespace std;

// Here are some Formula's for calculating compound interest on a mortgage loan
//Note: ^ means power, therefore P(1+r) is raised to the power of n (number of years for loan)
//A=P(1+r)^n
//A - total cost of mortgage plus interest
//P – principal
//r – interest rate
//n – number of years


//My job is to Your first programming task is to create a program to determine
//whether or not an applicant qualifies to receive a home loan based on his/her ability to repay a mortgage.
int main()
{
// Declare Variables
    int years = 20;
    char response,response2,response3;
    double purchasePrice;
    double downPayment;
    double principal;
    double interestRate = .05;
    double down_pmt_pct;
    double insuranceRate; //cost of homeowners insurance is at the rate of $250 per $50,000, 750 = 125000
    double annualIncome;
    double monthlyDebt;
    double total_compoundInt;
    const double meckTax = .015;
    const double cabTax = .012;
    const double debtincomeRatio = .28;  //28% constant rate
    const double seniortaxDiscount = .002; // 65 or older and military


// Ask for Inputs

    cout << "How much does the house cost?" << endl;
    cin >> purchasePrice;

    cout << "How much will the applicant pay up front?" << endl;
    cin >> downPayment;

    down_pmt_pct = 1 - (downPayment / purchasePrice);
    if (down_pmt_pct < 0.20)
    {
    cout << "This loan requires mortgage insurance at 1%" << endl;
     interestRate += 0.01;
    }
    cout << "Which county do you live in? (M,C)" //M for mecklenburg and C for cabarrus
    cin >> response;

    cout << "Do you work for the military? (Y,N) "<< endl;
    cin >> response2;

    cout << "Are you 65 or older? (Y,N)" << endl;
    cin >> response3;
    if (response = C )
    {
        if (response2 = Y || response3 = Y)
            cabTax -= .02
    }

    cout << "How much money do you make in a year?" << endl;
    cin >> annualIncome;

    cout << "How much do you pay for any other monthly debts?" << endl;
    cin >> monthlyDebt;
// Calculations
    principal = purchasePrice - downPayment
    total_compoundInt = principal(pow((1+interestRate),years))



// Ask for Outputs

    cout << "Did you qualify for the home loan?" <<  <<  endl; //add variable
    cout << "You can use this amount of money for debt from your monthly income:" <<  <<  endl;  //add a variable

    return 0;
}
Last edited on
Line 60, 62: You're using the assignment operator (=), not the equality operator (==).

Line 63: You can't decrement cabTax because it is declared const. Also, you have a const defined for seniortaxDiscount, but don't use it here.

Line 65: You want to have a single taxRate item here which contains either the mecklenburg tax rate, or the possibly adjusted cabarrus tax rate.

Line 74: You need to calculate the debt to income ratio.

I don't see any calculation of homeowners insurance. Both taxes and homeowners insurance need to be included in the debt to income ratio.
1
2
3
4
5
6
7
8
9
10
11
12
    if (response == C)
    {
        if (response2 == Y || response3 == Y)
          {
              cabTax -= seniortaxDiscount
          }
            else if(response2==Y && response ==Y)
            {
                cabTax -= (seniortaxDiscount + seniortaxDiscount)
            }
    }

Is there a reason why this part wont compile? The error is at the start
would the debt to income ratio be just total debt payments / my income?
How would I put the homeowners insurance as a calculation. Above it says every 50,000 dollars it increases by 250. so 100000 is 500 and 125000 is 750 and so on
Is there a reason why this part wont compile?

Line 1, 3, 7: Your character literals need to be enclosed in single quotes.
 
if (response == 'C')


would the debt to income ratio be just total debt payments / my income?

debt payments + mortgage payment. Insurance and taxes are often included, but are not mentioned in the instructions. Keep in mind that income is expressed as an annual amount, while debt is a monthly amount.

How would I put the homeowners insurance as a calculation
 
insurance = ceil(purchasePrice / 50000) * 250;


The ceil works but I just dont understand what it does to the thing.
And so for the Debt to income ratio am i just adding everything and dividing that by the annual income?
Last edited on
The ceil works but I just dont understand what it does to the thing.

http://www.cplusplus.com/reference/cmath/ceil/
Rounds x upward, returning the smallest integral value that is not less than x.

purchasePrice / 50000 yields a fractional number of units. e.g. 75,000 / 50000 = 1.5 units. Since homeowners insurance is only sold in $50,000 units, we need to round up the number of units of insurance before multiplying by the cost per unit.

And so for the Debt to income ratio am i just adding everything and dividing that by the annual income?

You have to decide if you're going to include the cost of insurance and taxes in your debt ratio. The instructions are not clear on this.

I already cautioned you that the monthly debt ratio is calculated from the sum of the monthly debts devided by the MONTHLY income. You're going to have to calculate the monthly income from the annual income.

The instructions for this assignment are really pretty clear. You shouldn't be having this much trouble.




Topic archived. No new replies allowed.