I have two function in the same class. In the first function I return a value, and I need to use this value in another function. I am returning by value.
double Loan::monthlyPayment(double anAmount, double anInterestRate, int term){
double payment = ((anAmount * anInterestRate ) * ((anInterestRate +1)/((anInterestRate +1)*exp(term)-1)));
return payment;
}
I need to access the returned payment in this function:
/*
The Loan class should have a makePayment(double amount) method that
allows payments to the loan to be made. A payment is assumed to
happen once a month. When a payment is made the balance is first
increased by 1/12 of the interest rate and then the amount is
subtracted from the balance. Modify the main program given to
demonstrate that this method works properly.
*/
double Loan::makePayment(double amount){
// Get the amount to pay
amount = monthlyPayment(???)+(1/12)(term);
return amount;
}
Also, how do I access the returned value from this makePayment(amount) function in another class?
Thank you!