Read this closely. There is a specific code you have to follow shown below and t
ID: 3859330 • Letter: R
Question
Read this closely. There is a specific code you have to follow shown below and the professor wrote some code down that you CANNOT change. People keep changing his code, even though he stricktly says to leave that alone. What I need help with is ONLY to change the code with, "YOUR CODE HERE". Don't change anything below "int() main".
Please make sure your output matches the example outputs he provided - there are 2.
Thanks for your help!
CMPSC 101 LAB 12 - Loan payment with functions Write a program that asks the user for a loan amount, an annual interest rate, and a monthly payment amount; call a function called payoff which displays a list of the account month by month and then returns the number of months needed to payoff the loan. For example Please enter loan amount: 1000.00 Please enter monthly payment: 100.00 Please enter annual interest: 5.00 Interest rate per month is 0.42 Mon: 1 Bal: 1000.00 + Int:4.17 - Pay:100.00 Mon: 2 Bal: 904.17+ Int:3.77 - Pay:100.00 Mon: 3 Bal: 807.93 Int:3.37 - Pay: 100.00 Mon: 4 Bal: 711.30 + Int:2.96 - Pay: 100.00 Mon: 5 Bal: 614.26+ Int:2.56 - Pay:100.00 Mon: 6 Bal: 516.82 Int:2.15 - Pay:100.00 Mon: 7 Bal: 418.98 + Int:1.75 - Pay:100.00 Mon: 8 Bal: 320.72 + Int:1.34 - Pay:100.00 Mon: 9 Bal: 222.06 + Int:0.93 - Pay:100.00 Mon 10 Bal: 122.98+ Int:0.51 - Pay:100.00 Last payment: 23.50 It will take 11 months to pay off the loan. Also, make sure the loan does not take more than 360 payments (30 years + a payoff) For example, if a loan will cost more in interest than the payments, it will never end, so we need to trap for that: Please enter loan amount: 50000.00 Please enter monthly payment: 400.00 Please enter annual interest: 10.00 Interest rate per month is 0.83 Mon: 1 Bal: 50000.00 Int:416.67Pay:400.00 Mon: 2 Bal: 50016.67 + Int:416.81 - Pay: 400.00 Mon: 3 Bal: 50033.47 + Int:416.95 - Pay:400.00 Mon: 4 Bal: 50050.42 + Int: 417.09 -Pay: 400.00 Mon: 5 Bal: 50067.50 + Int: 417.23 - Pay: 400.00 Mon: 6 Bal: 50084.73+ Int:417.37 - Pay: 400.00 Mon: 357 Bal: 86379.40 Int:719.83-Pay: 400.00 Mon: 358 Bal: 86699.23 + Int: 722.49 - Pay: 400.00 Mon: 359 Bal: 87021.73 + Int: 725.18 - Pay: 400.00 Mon: 360 Bal: 87346.91 + Int: 727.89 - Pay: 400.00 Report was stopped, does not seem to endExplanation / Answer
int payoff(double loan, double payment, double interest){
double count = 0;
while(loan > payment) {
amount = amount + amount * (interest/100) - payment;
count++;
}
return count;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.