Question: Loops Exercise 1: For-Loop: Loan Pay-off (10pt) Consider a personal loan of $50,000. The monthly interest rate is 0.5% (i.e., APR 6%). Suppose a fixed

 Loops Exercise 1: For-Loop: Loan Pay-off (10pt) Consider a personal loan
of $50,000. The monthly interest rate is 0.5% (i.e., APR 6%). Suppose

Loops Exercise 1: For-Loop: Loan Pay-off (10pt) Consider a personal loan of $50,000. The monthly interest rate is 0.5% (i.e., APR 6%). Suppose a fixed monthly payment of $1,000 is to be made at the beginning of each month. How many months will it take to pay off the loan? Notice that interests accrue every month on the unpaid balance. Write a simple Java program using a for loop (REQUIRED) to show the process of paying off a personal loan. Display the first 12 months' loan payment process. Save the code as Hw4_Ex1.java. The expected output is as follows: OS. Command Prompt Interest C:\test>javac Hw4_Ex1.java C:\test>java Hw4_Ex1 Month Payment Amount Un paid 1000.00 49000.00 1000.00 48245.00 1000.00 47486.23 1000.00 46223.66 1000.00 45957.27 1000.00 45187.06 1000.00 44413.00 1000.00 43635.06 1000.00 42853.24 10 1000.00 42067.50 11 1000.00 41277.84 1000.00 40484.23 New Balance 49245.00 48486.23 47223.66 46957.27 46187.06 45413.00 44635.06 43853.24 43067.50 42277.84 41 484.23 40686.65 206.39 202.42 C:\test> The initial balance at the beginning of the first month is $50,000.00, after the payment of $1,000.00, the amount unpaid is $49,000.00, which accrues interest of $245.00 (=49000*0.005), making the new balance $49,245.00. Such a process repeats month after month as long as the balance remains positive. Hint: You may use the following code snippet to specify the output format: ...printf("%60 810.2f $15.2f $10.2f $15.2f ", ...,...,...,..., ...)... Exercise 2: While-Loop: Loan Pay-off Revisited (10pt) Now let us revisit Exercise 1 and use a while loop to do the task. We want to allow the user to enter any the loan amount, the monthly payment amount, and the monthly interest rate; the program will find out how many months it will take to pay off the loan. Write a simple Java program using a while loop (REQUIRED) to show the answer. Save the code as Hw4_Ex2.java. The expected output is as follows: ONCommand Prompt C:\test>javac Hw4_Ex2.java C:\test>java Hw4_Ex2 Loan amount: 50000 Monthly payment: 1000 Monthly interest rate: 0.005 Months it takes to pay off the loan: 58 C:\test> Note: in this exercise, you do NOT need to print out the entire loan payoff process (but you still need to track the loan payoff process through the loop to find out the answer)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!