Page 1 of 1

The assignment is asking to write a single function that returns multiple values by using the concept "Passing by Refere

Posted: Thu Jul 14, 2022 2:12 pm
by answerhappygod
The assignment is asking to write a single function that returnsmultiple values by using the concept "Passing by Reference". We usethis assignment to assess if you understand the concept of "Passingby Reference".
Without using global variables, write a C++ program thatcontains a function (other than main() function) that calculatesthe monthly payment of a mortgage. The function will receive (willhave inputs) loan amount, annual interest rate, and the term (thenumber of years to pay off the loan), and returns the monthlypayment, total payment, and the total interestspaid. Do not include any cin nor cout statementsinside of the function, in other words, the function don'tdisplay any calculation results, it returns calculation results,such as monthly payment, total payment, and the total interestspaid to the caller. The caller function will display thecalculation results. (Make sure no calculation made in main()function, the main() receives the calculation results from thefunction calls and displays those results on the screen).
More specifically, in the main() function, using a a loopingstatement to allow a user to repeatedly use the function for thecalculation.
Following are the formulas used for the calculation:
The Assignment Is Asking To Write A Single Function That Returns Multiple Values By Using The Concept Passing By Refere 1
The Assignment Is Asking To Write A Single Function That Returns Multiple Values By Using The Concept Passing By Refere 1 (52.51 KiB) Viewed 16 times
Monthly Payment: R=[1200r​1−(1+1200r​)−12t​]A​ Total Payment: R×(12t) Total Interests Paid: Total Payment - A Where R is the monthly payment, A is the loan amount, r is the annual interest rate, and t is the term (The number of years to pay off the loan).
Here is a sample run of the program: Please enter any number to continue, and enter θ to finish. 1 Please enter the loan amount: 200000 Please enter the interet rate: 4.3 Please enter the term: 15 Your monthly payment is 1509.62 Your total payment will be 271732 Total interets paid will be 71732.1 Please enter any number to continue, and enter θ to finish. 0 Program ended with exit code: θ