Use of an array for the different loans


Assignment:

Q: Modify the below program so it will satisfy the below requirements:

Write the program as a procedural C++ program. Allow the user to input the amount of a mortgage and then select from a menu of mortgage loans:

- 7 year at 5.35%
- 15 year at 5.5%
- 30 year at 5.75%

Use an array for the different loans. 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. Allow the user to loop back and enter new data or quit. Insert comments in the program to document the program. //header file

#include

#include

#include

using namespace std;

int main ()

{

int term = 0;

int months = 0;

float principle = 0.0;

float annualPercent = 0.0;

float rate = 0.0;

float monthlyPayment = 0.0;

float totalPayment = 0.0;

int menuSelection = 0;

do{

cout << "Please enter the loan amount ($): ";

cin >> principle;

cout << "Please enter the loan term (year): ";

cin >> term;

cout << "Please enter the loan rate (%): ";

cin >> annualPercent;

cout << endl;

cout << "Please wait ...";

cout << endl << endl << endl;

rate = annualPercent / 1200.0;

months = term * 12;

monthlyPayment = (rate + rate/(pow(1+rate, months) -1)) * principle;

totalPayment = monthlyPayment * months;

cout.setf(ios::fixed);

cout.setf(ios::showpoint);

cout.precision(2);

cout << "The total mortgage payment = "

<< totalPayment << endl;

cout << "Would you like to calculate another loan? (0 - no, 1 - yes)" << endl;

cin >> menuSelection;

} while(menuSelection == 1);

cout << endl << endl;

cout << "Thank you for using our loan calculator." <

cout << "Goodbye!" << endl;

cout << endl << endl;

return 0;

}

Solution Preview :

Prepared by a verified Expert
C/C++ Programming: Use of an array for the different loans
Reference No:- TGS01937583

Now Priced at $20 (50% Discount)

Recommended (91%)

Rated (4.3/5)