Explore BrainMass

C++ OOP Problem

I need help, I can't seem to get my program right. I have a tendency to do it in Java and not C++. Thanks

Write the program as an object-oriented C++ program that allows 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 a new amount and make a new selection, or quit. Insert comments in the program to document the program.

- Make sure to use inheritance.
- Make sure you use public and private members in the class definitions.
- Your program should validate all user input (simple value range validation). If value is invalid, an appropriate message should be displayed and the user is asked to re-enter the value. This continues until the user enters a valid input.
- Include a design flow chart or psuedocode algorithm.
- Don't over engineer the program.
#include <iostream>
#include "math.h"

using namespace std;

double calcPayment(double principle, double rate, double term) {

// Calculating the monthly payment: M = P [ i(1 + i)n ] / [ (1 + i)n - 1]
double monthlyRate = rate/12.0;
double t = pow((1 + monthlyRate),term);
double payment = (principle * monthlyRate * t) / (t-1);

void cont() {
char junk;
cout << "Press a key and enter to continue";
cin >> junk;

void displayAmort(double principle, double rate, double term, double payment) {

double monthlyRate = rate/12.0;

for (int i=1;i<=term;i++) {
principle = principle + (principle * monthlyRate);
principle = principle - payment;

cout << i << "t" << principle << endl;

if (i%24==0) {

int main() {

// Declaring and initializing the variables
double principle = 0;
double interestRate = 0;
int term = 0;
double payment = 0;
bool done = false;
char ch;

while (!done) {

// Prompt and get values from the user
cout << "Enter principle: ";
cin >> principle;
cout << "Enter rate: ";
cin >> interestRate;
cout << "Enter term: ";
cin >> term;

// Calculate the payment by calling a function
payment = calcPayment(principle,interestRate,term);

//Display the results on computer screen
cout << "Calculating the monthly payment of a 30 year $200,000 loan at 5.75% interest." << endl;
cout << "The monthly payment is " << payment << endl;

displayAmort(principle, interestRate, term, payment);

cout << "Again? (y/n):";
cin >> ch;
if (ch != 'y') {
done = true;

Solution Summary

This solution is provided in a .zip file which is attached. A flow chart has been completed for this response in a Word document which can be found when opening the .zip file.