Modify the code-input the amount of a mortgage


Assignment:

Q: Modify your program so that the user will input the amount of a mortgage after selecting from a menu of mortgage loans:

- 7 years at 5.35%

- 15 years at 5.5%

- 30 years at 5.75%.

Use an array of structures for the information about the different loans.

Your program should begin by prompting the user with a menu to select a mortgage type or to exit. Once a specific loan is selected, display the mortgage payment amount. Then, list the loan balance and interest paid for each payment over the term of the loan. On longer term loans, the list will scroll off the screen. Do not allow the list to scroll off the screen, but rather display a partial list and then allow the user to continue the list. Return to the menu prompt after presenting the information. Insert comments in the program to document the program.

Your program should also follow all my formatting guidelines. The final program must be completely viewable and executable when I run the code from the Microsoft Visual C++ development system. Error checking should be limited to validating that all amounts entered are positive.

The user should be told what the invalid entry was and why it was invalid if they enter a zero or negative amount. They should then be prompted again to reenter a valid amount.

The program should use at least three distinct classes including an abstract base class with at least one virtual method. A concrete class must inherit from this base class and implement any abstract methods in the base class. Each method should have a limited scope and your classes should implement several methods, each of which implements a small part of the task. Do not lump all the functionality into a single class. While the exact format of your classes and structure is up to you, I expect your code to look good and be easy to read and understand.#pragma once
#include "prg411menu.h"

using std::cout;

int main()
{

char restart;

Menu showMenu;// Set up screen for input
//

showMenu.displayMenu();
showMenu.getPrinciple();
showMenu.getInterest();
showMenu.getTerm();

calc calcPmt;

calcPmt.calculatePayment();

cout << "Your monthly payments will be: tiny_mce_markerquot; << mnthPmt << endl;//Advises users of payment

cout << " Would you like to enter different figures? (Y/N)" << endl;// Allows user to continue or quit

cin >> restart;

if ((restart == 'y') || (restart == 'Y'))
{
return main();

}
else

return 0;
};

#include "Menu.h"
#pragma once
#include

//Base class function for the Display Menu "PRG411Menu.h"
class Menu
{
public:
virtual void displayMenu() const = 0;

//__________________________________________________________________________
// PURPOSE: To create a mortgage calculator with user input and menu that declares 3 different interest rates.

//
#pragma once
#include
#include "loan.h"

using std::cout;
using std::cin;
using std::endl;

class Menu
{
public:

//Title menu and information about the mortgage program
void displayMenu() const
{

cout << "\t\t**********************************************" << endl
<< "\t\t* Welcome to the #1 Mortgage Calculator *" << endl
<< "\t\t**********************************************" << endl << endl;
cout << endl << "***By: Taakella N. Milton ***" << endl ;
<< "****Please follow prompts to enter your requested data and/or quit***" << endl ;
return;
}

//User is prompted to enter loan amount (PRINCIPLE)
void getPrinciple()
{
double loanPrinciple;
cout << "Enter your loan amount ($): " << endl;
cin >> loanPrinciple;
return;
}

//User is prompted to enter interest rate
void getInterest()
{
double loanInterest;
cout << "Enter your loan rate (%): " << endl;
cin >> loanInterest;
return;
}

//User is prompted to enter loan (TERM) in years
void getTerm()
{
double loanTerm;
cout << "Enter your loan term (year): " << endl;
cin >> loanYears;
loanTerm = (loanTerm * 12);//Based on # months in year
return;
}
};

// PRG411MORTCALC2.cpp : Defines the entry point for the console application.
// PURPOSE: To create a mortgage calculator with user input and menu that declares 3 different interest rates.
//
//
#include
#include // Math function library
#include // I/O manipulation library for output
#include "Prg411Mortage.h"
using namespace std;
//
//
// FUNCTION NAME: CalculateMortgage
//
// PURPOSE:
// User to ent.eter mortgage amount in terms of rate, year and amount.
//
//
//
//
//
void CalculateMortgage()
{
//Declare variables
double loanAmount;
double loanYears;
int interestRate;

do

void Calculator::readInput1()
{
cout << "\nPlease enter your MORTGAGE LOAN amount ($)? ";//User should enter amount as decimal
cin >> loanAmount //User inputs Data in dollars for Loan Amount
while((loanAmount == 0) || (loanAmount < 0))// Checks for correct dollar amount entered
{
if(loanAmount == 0)
{
cout << "You have enterned an INVALID amount. Amount must be more than zero dollars!" << endl
<<"\nPlease enter total mortgage amount in dollars again";
cin >> loanAmount;
}
}
if(loanAmount < 0)
{
cout << "You have entered an INVALID amount. Amount must be more than zero dollars!" << endl
<< "\nPlease enter total mortgage amount in dollars again! ";
cin >> loanAmount;

}

}

return;

}
}

void Calculator::readInput 2()
{
cout << "\nPlease enter your loan TERM (years) ";
cin >> loanYears;// User to enter number of years for loan
while((loanYears == 0.00) || (loanLengthYears < 0.00))//Checks data input
{
if(loanYears == 0.00)
{
cout << "0 is not a valid amount. Please try again" << endl
<< "\nWhat is the length of the loan in years? ";
cin >> loanYears;

}

if(loanYears < 0.00)
{
cout << "That amount is negative. Please put in a positive amount" << endl
<< "\nWhat is the length of the loan in years? ";
cin >> loanYears;

}

}

return;

void Calculator::readInput3()

{
cout << "Please enter the INTEREST RATE (percent)(.)!";// User should enter rate as decimal for percent
cin >> interestRate; //User inputs Data in percent
while((interestRate == 0.00) || (intRate < 0.00)) //Checks for correct input
{
if(interestRate == 0.00)
{
cout << "You have entered an invalid. Percent must be more than zero!" << endl
<< "\nPlease enter total mortgage percent again! ";
cin >> interestRate;

}

if(interestRate < 0.00) //If user was to enter rate less than zero percent (decimal)
{
cout << "That amount is negative. Percent must be more than zero!" << endl
<< "\nPlease enter total mortgage percent again! ";
cin >> interestRate;

}

}

return;

}
{
double loanAmount;
double yearlyRate;

MortgageCal morgCalc;
char indicator = ('y', 'Y'); // set indicator to 'y' for continue...
while ((indicator =='y') || (indicator == 'Y')) // to continue loop as long as input = y
{

// I/O Set up screen output to display mortgage amount, interest
//rate and loan in years.

loanAmount = getRangedInput("Please enter the loan amount", 0, numeric_limits::max());
cout << endl;
term = getRangedInput("Please enter the loan term in years", 0, 10000);
cout << endl;
loanYears = getRangedInput("Please enter the yearly interest rate", 0, 100);
cout << endl;
morgCalc.setLoanAmount(loanAmount);
morgCalc.setLoanYears(term);
morgCalc.setInterestRate(yearlyRate);

}
//
//
// FUNCTION NAME: main
//
// PURPOSE: The main function calls get input function, then the create message,
// function. The if statement checks to see if the user would like to continue, and exits the application if not.
//
// NOTES:
//
//
//
//
int main()
{
//local variable declaration
char userresponse;
//
//checks the users reponse to continue, if yes then recall functions, if not exits.
do
{
CalculateMortgage();
cout<< "\nWould you like to continue and enter new figures?";
cin>> userresponse;
}while ((userresponse == 'y') || (userresponse == 'Y'));

return 0;

}

Solution Preview :

Prepared by a verified Expert
C/C++ Programming: Modify the code-input the amount of a mortgage
Reference No:- TGS01937223

Now Priced at $30 (50% Discount)

Recommended (91%)

Rated (4.3/5)