Computer Networking: A Top-Down Approach (7th Edition)
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN: 9780133594140
Author: James Kurose, Keith Ross
Publisher: PEARSON
Bartleby Related Questions Icon

Related questions

Question

Code a Mortgage calculator

using c++ and Microsoft visual Studio create a new project called exercise2 and use the code attached as exercise2.cpp.

This mortgage calculation program obtains from the user a number of parameters including size of the loan, number of years, percent yearly interest rate, and the number of payments per year. It then calculates the size of the payments and the total paid over the life of the loan.  (Note that the user enters percent annual interest rate while the formula uses decimal interest per year! Pay attention to variable names.)

Remember to test your program by trying all different possible combinations of input. When testing your program, be sure to enter some incorrect data, such as text instead of numbers, decimal percentage rate instead of integer percentage rate, and unfilled fields to witness how the program behaves.  Your program does not have to correct for bad input, but it should accept interest as percent per year.

Note the use of really good variable names and the correct types. Don’t use int when you need a real number or double when you need an integer. The intermediate variable decIntRatePerPayment is a number between zero and one, not a percentage.  In most cases the user knows the Annual Interest Rate rather than the decimal interest per payment.   Loan duration is a positive integer while decimal interest per year is a real number. Use the formulas below to calculate the payment size.
 

Note that the quantity within the parentheses is raised to the negative of the total number of payments.  As a test case, a $100,000 loan at 8% for 15 years has a payment of $955.65 per month. Note that the factor formula uses the decimal interest per payment, not the percent interest per year obtained from the user.

Note: if x and y are doubles, then pow(x, y) will raise x to the power of y.

When you are finished, exercise2.cpp and submit it. 

sample code:

/***********************************************
 * mortgage Calculator. <your name> <date> Given principle amount, percent interest
 * per year, loan duration in years, and number of payments per year, calculates
 * the payment size. Note intercap naming convention and CONSISTANT abbreviations(!)
 * code modified from code provided by David Beard.
 */
#include <iostream>  // includes system I/O software

using namespace std;  // eliminates the need for std::

int main()
{
    double loanAmount;
    double percentInterestRatePerYr; // if abbreviate year w/ yr, they always use yr
    long loanDurationInYrs;
    long numPaymentsPerYr;
    double paymentSize = 42;
    double decIntRatePerPayment;
    long totalNumOfPayments = 42;
    double factor;
    double totalOfAllPayments;
    // obtain information from user
    cout << "Mortgage Calculator V1.0" << "\n";
    cout << "Please enter the Principal: ";
    cin >> loanAmount;

    cout << "Please enter the interest rate: ";
    cin >> percentInterestRatePerYr;

    // add code to obtain loan duration and number of payments per year from user


    // calculate intermediate results for the following:
    decIntRatePerPayment = 
    totalNumOfPayments = 
    factor = 
    paymentSize = 
    totalOfAllPayments =

    // display results to user
    cout << "The payment size is: " << paymentSize << "\n";
    // add a cout for the total of all payments
    return(0);
}

Expert Solution
Check Mark
Knowledge Booster
Background pattern image
Computer Engineering
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-engineering and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Text book image
Computer Networking: A Top-Down Approach (7th Edi...
Computer Engineering
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:PEARSON
Text book image
Computer Organization and Design MIPS Edition, Fi...
Computer Engineering
ISBN:9780124077263
Author:David A. Patterson, John L. Hennessy
Publisher:Elsevier Science
Text book image
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:9781337569330
Author:Jill West, Tamara Dean, Jean Andrews
Publisher:Cengage Learning
Text book image
Concepts of Database Management
Computer Engineering
ISBN:9781337093422
Author:Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:Cengage Learning
Text book image
Prelude to Programming
Computer Engineering
ISBN:9780133750423
Author:VENIT, Stewart
Publisher:Pearson Education
Text book image
Sc Business Data Communications and Networking, T...
Computer Engineering
ISBN:9781119368830
Author:FITZGERALD
Publisher:WILEY