The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Jul 2017 |
| Last Sign in: | 313 Weeks Ago, 6 Days Ago |
| Questions Answered: | 15833 |
| Tutorials Posted: | 15827 |
MBA,PHD, Juris Doctor
Strayer,Devery,Harvard University
Mar-1995 - Mar-2002
Manager Planning
WalMart
Mar-2001 - Feb-2009
Hi could you please help me with this C++ questions?
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.67 - Pay: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 end.
Â
Start with this code;
#include<iostream>
// YOUR CODE HERE
// TO HERE!
// DO NOT CHANGE ANYTHING BELOW
double loan, payment, interest;
cout.setf(ios::fixed, ios::floatfield);
cout.precision(2);
cout<< "Please enter loan amount: ";
cin>> loan;
cout<< loan <<endl;
cout<< "Please enter monthly payment: ";
cin>> payment;
cout<< payment <<endl;
cout<< "Please enter annual interest: ";
cin>> interest;
cout<< interest <<endl;
intnumMonths = payoff(loan, payment, interest);
if (numMonths != -1) {
cout<< "It will take " <<numMonths;
cout<< " months to pay off the loan." <<endl;
}
return 0;
}
Â
----------- He-----------llo----------- Si-----------r/M-----------ada-----------m -----------Tha-----------nk -----------you----------- fo-----------r y-----------our----------- in-----------ter-----------est----------- an-----------d b-----------uyi-----------ng -----------my -----------pos-----------ted----------- so-----------lut-----------ion-----------. P-----------lea-----------se -----------pin-----------g m-----------e o-----------n c-----------hat----------- I -----------am -----------onl-----------ine----------- or----------- in-----------box----------- me----------- a -----------mes-----------sag-----------e I----------- wi-----------ll -----------be -----------qui-----------ckl-----------y