I'm not really sure where to go with this one. The object of the program is to calculate the loan payment given the input of the annual interest rate, term, and amount. I know the calculation part of it is correct because I've used it before. However, I cannot incorporate it in an inheritance set up. Please help.
MY BASE CLASS IS...
CODE
#include <iostream>
#include "justin.h"
#include <math.h>
using namespace std;
void main ()
{
float Amt, AR, i, n;
cout << "Enter the amount of money borrowed ";
cin >> Amt;
cout << "Enter the annual interest rate in percentage form ";
cin >> AR;
i = AR/1200;
cout << "Enter the term in months ";
cin >> n;
Final Loan(Amt, AR, i, n);
cout << "The monthly payment of your loan is "<<Loan.calculate_loan<<endl;
cout << "The specifications you entered of the Amount, Annual Rate, and Term are "<<endl;
Loan.display_loan()<<"respectively"<<endl;
}
MY DERIVED CLASS IS...
CODE
#include <iostream>
#include <math.h>
using namespace std;
class Final
{
public:
Final();
Final(float, float, float, float);
float calculate_loan(float);
void display_loan();
private:
float Amount;
float Annual_rate;
float monthly_rate;
float term;
};
Final::Final(float AMT, float ar, float I, float N)
{
Amount = AMT;
Annual_rate = ar;
monthly_rate = I;
term = N;
}
float Final::calculate_loan(float MP)
{
return MP = (i +(i/((pow((1 + i),n))-1))) * Amt;
}
void Final::display_loan()
{
cout <<Amount<<","<<Annual_rate<<","<<term<<endl;
}