Question

For this assignment please complete the following exercise. Submit your completed source code (*.cpp) and screenshots...

For this assignment please

complete

the

following exercise. Submit

your completed

source code

(*.cpp) and screenshots

demonstrating you successfully ran the program by the due date.

========

Mortgage Class

Design a class

that will represent a

home mortgage. The constructor should accept the loan

amount, interest

rate,

and

number of years

to pay off the loan.

The class

should have member

functions for returning the monthly

payment amount and

the

total

amount paid to the

bank at the end

of the loan period.

The monthly

payment with interest

compounded

monthly can be calculated as follows:

where

Payment = the monthly payment

Loan = the dollar amount of the loan

Rate

= the annual interest rate

Years =

the number of years

of the

loan

Utilize the class in a complete program. Run the

program at least

three times with

different

values to

demonstrate it works correctly.

Input Validation: Do not accept negative numbers for any of

the

loan values.

values to

demonstrate it works correctly.

Input Validation: Do not accept negative numbers for any of

the

loan values.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

/* *program : for calculating the mortgage loan. program uses constructor that accepts the loan amount, rate and years and the function to calculate the monthly payment, amount to be paid to bank at the end */

#include <cstdlib>

# include<math.h>

#include<iostream>

using namespace std;

/*

* Mortage calculator

*/

class Mortage{

public :

double payment, loan, rate, total, final_amount;

int years, term;

//parameterized constructor for accepting loan amount, rate, no.of years

Mortage(double x, double y, int z){

loan = x;

rate = y;

years = z;

}

/* month_pay() member function to calculate the compound interest of the

loan to be paid monthly*/

double month_pay(){

term = years*12;

total = ((loan * rate) / (1 - pow(1+rate,-term)));

return total;

}

/*total_amount() calculate the final amount to be paid for the bank*/

double total_amount(){

int term = years*12;

final_amount = term * month_pay();

return final_amount;

}

};

int main(int argc, char** argv) {

double l,r;

int yrs,choice;

// accept the loan amount, rate, no.of years

cout<<"\nEnter the loan Amount:";

cin>>l;

  

cout<<"\nEnter the Rate :";

cin>>r;

cout<<"\nEnter the No. of Years :";

cin>>yrs;

// perform the function if its positive values

if((l>0)and(r>-1)and(yrs>0)){

r = r/100;

Mortage m1(l,r,yrs);

cout<<"\nmonthly amount to be paid : " <<m1.month_pay();

cout<< "\nfinal amount to be paid to bank : "<<m1.total_amount();

}

//if the value is negative display the comment

else

{

cout<<"For calculating the loan amount, enter positive values";

}

return 0;

}

sample output:

Enter the loan Amount:50000

Enter the Rate :4.5

Enter the No. of Years :8

monthly amount to be paid : 2283.37
final amount to be paid to bank : 219204

output 2:


Enter the loan Amount:40000

Enter the Rate :-5

Enter the No. of Years :6
For calculating the loan amount, enter positive values

Add a comment
Know the answer?
Add Answer to:
For this assignment please complete the following exercise. Submit your completed source code (*.cpp) and screenshots...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • 2. Complete the % Down column by correctly calculating the percentage of the cost of the...

    2. Complete the % Down column by correctly calculating the percentage of the cost of the house that the customer’s down payment represents. 3. Complete the APR column by using the VLOOKUP function and the table for Years and Rate provided to assign the correct interest rate to each loan based on the length of the loan in the Years column. 4. Complete the Monthly Payment column using the Payment (PMT) function to correctly calculate the monthly payment due for...

  • L You will only receive credit on the shels labell your You th or complete photocopy). You may Mathematics Map the...

    L You will only receive credit on the shels labell your You th or complete photocopy). You may Mathematics Map the origin them which you w ch You otherwiecie 3 Q008 Negative Amortization Negative amortization occurs when the principal balance on a loan (usually a morte) increases because the borrower's payments don't cover the total amount of interest that has accrued. Thomas decides to purchase a house that costs $294,000. The bank requires a 10% downpayment and will provide a...

  • c++ and please add tables and everything and make sure program is complete. Write a menu...

    c++ and please add tables and everything and make sure program is complete. Write a menu driven program, which would compute compound interest and a monthly payment for a loan. The user will be given a choice to display the info on the screen or to a filo Menu will be the following Enter (1) to calculate your loan monthly payment Enter (2) to calculate your loan monthly payment & write to a file Tips: Compound Interest Formula A =...

  • C++ Please complete the implementation of the following source code (Question3.cpp). You need to add your...

    C++ Please complete the implementation of the following source code (Question3.cpp). You need to add your code in the source code where the comment “// your code” locates. After you finish the implementation, please also provide the output of your program. #include <iostream> using namespace std; class Shape { protected: // your code public: void setWidth (int w) { // your code } void setHeight (int h) { // your code } }; class Rectangle: public Shape { public: int...

  • PLEASE HELP, MATLAB, answers are very appreciated need to study pl 2. Write two m-file functions...

    PLEASE HELP, MATLAB, answers are very appreciated need to study pl 2. Write two m-file functions that will allow you to compare mortgages cakculations for the monthly payment and compare mortgage with different loan values. The monthly payment M, is calculated using 1-2)1 Where Pis the principal loan amount, r is the interest rate (in decimal form not percent form), and y is the number of years of the loan. Create an m-file function called "mortgage_a.m" that will serve as...

  • Please show complete work. Thank you -) At what effective rate of interest will be present...

    Please show complete work. Thank you -) At what effective rate of interest will be present value of $1,000 at the end of 2 years and $3,000 at the end of 4 years be equal to $10,000? 2) John loves sports cars and needs to finance $25,000 of total purchase price of a new cam A loan is selected having 48 monthly level payments with a lender charging 6% convertible monthly. However, the lender informs the buyer that their policy...

  • Complete the following table: (Use Table 15.1) (Do not round intermediate calculations. Round your answers to...

    Complete the following table: (Use Table 15.1) (Do not round intermediate calculations. Round your answers to the nearest cent.) First Payment Broken Down Into— Selling price Down payment Amount mortgage Rate Years Monthly payment Interest Principal Balance at end of month $136,000 $30,000 $106,000 6.5% 30 $ $ $ $

  • THE PROBLEM: The nice folks from the Lion Lending Company have hired you to write some...

    THE PROBLEM: The nice folks from the Lion Lending Company have hired you to write some software that will process their daily loan information. The data will come from a text file that has the following format: The first line will contain an integer: number of loan applications There will be two rows for each of the customers First line will be the customer's (1) first name and (2) last name, separated by a space (assume there is no spaces...

  • Your program will ask the user to enter the amount of money they want to borrow,...

    Your program will ask the user to enter the amount of money they want to borrow, the interest rate, and the monthly payment amount. Your program will then determine how many months it will take to pay off that loan, what the final payment amount will be, and how much interest was paid over that time. If the monthly payment amount isn't high enough to pay off more than one month's interest, your program should notify the user what the...

  • 1. Complete the following table. Number of Annual Payments or Years Present Value Interest Rate Future...

    1. Complete the following table. Number of Annual Payments or Years Present Value Interest Rate Future Value Annuity 10 $250.00 12% 20 S1,000 25 S500,000 30 S1,000,000 2. You just started working and you planned to save $5,000 every year in your retirement account. How much money will you have in your retirement account once you retire in 40 years? Your retirement account pays 4% interest rate per year. 3. You just retired with S1,000,000 savings. You'd like to receive...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT