the funciton need to pass values by reference not by value It is desired to crea
ID: 3629826 • Letter: T
Question
the funciton need to pass values by reference not by value
It is desired to create a mortgage estimator by writing a program containing a function. The user inputs the amount of loan (L), the loan term in number of months (N), and the annual interest rate (I). The program should make use of a function that accepts these values as Inputs through its argument and calculates and returns the monthly payment and the total payments ever the Ste of the loan. The monthly payment and the total payment could be calculated using the following expressions: monthly_payment = L/[1 -(1 + I/12)-N/I/12]. total_payment = N times monthly_payment Note that the interest rate must be expressed in decimal, for example, if the interest rate is 8% it must be entered as 0.08. Test your program for several scenarios and submit the results with the program listing. The values of L, N, I, monthly_payment, and total_payment should be written to a file as listed below;Explanation / Answer
Here is the basic program. You did not specify if it needed to take more than one value per run, so I made it take just one. Modifying it to take more than one should be easy. -------------------------------------------------------------------------------------------------- #include #include #include #include using namespace std; bool estimatePayments( const double amount, const double months, const double interest, double & monthly_payment, double & total_payment ) { if( interest > 1.0 ) return false; monthly_payment = amount / ( ( 1 - pow( 1 + interest / 12, -months ) ) / ( interest / 12 ) ); total_payment = months * monthly_payment; return true; } void outputHeader( ofstream & file ) { ostringstream os; osRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.