Question
1) Youve been hired by Lizard Lenders to write a C++ console application that determines the number of months to repay a car loan. Use
1) Youve been hired by Lizard Lenders to write a C++ console application that determines the number of months to repay a car loan. Use a validation loop to prompt for and get from the user the car loan amount in the range $1,000-5,000. Then use a validation loop to prompt for and get from the user the monthly payment in the range $100-500. Then use a validation loop to prompt for and get from the user the annual interest rate in the range 2-5%. Convert the valid rate to a monthly rate and to a decimal number with formula:
rate / 12 / 100
Loop to show the loan being repaid and keep track of the number of months it takes to do so. Before the loop, initialize the balance to the loan amount and months to zero. Within the loop, calculate the interest portion of each monthly payment, the principal portion of the payment, and the new balance with formulas:
interest = balance * rate;
principal = payment - interest;
balance = balance - principal;
Continue to loop while the balance is greater than zero. After the loop, print the number of months it took to repay the loan. Format the output in columns and show all real numbers to two decimal places. Here is sample output:
We l come to Lizard Lenders Enter the car loan amount (1K-5K): 2500 Enter the monthly payment (100-500): 400 Enter the annual interest rate (2-5%): 2 Balance($) 2104.17 1707.67 1310.52 912.70 514.23 115.08 284.73 Payment (S) 400.00 400.00 400.00 400.00 400.00 400.00 400.00 Principal(S) 395.83 396.49 397.15 397.82 398.48 399.14 399.81 Interest S)Principa Month 1 4.17 3.51 2.85 2.18 1.52 0.86 0.19 4 7 Months to repay loan: 7 End of LizardLenders
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started