Question

In: Computer Science

To model repayment of a loan, you need to calculate the interest on the balance and...

To model repayment of a loan, you need to calculate the interest on the balance and deduct any payments made. So if the balance at the start of the period is L the balance at the end of the period before the payment is L(1+r) where r is the interest rate per period (e.g. if the payments are monthly, it is a monthly interest rate) and the balance after the payment is L(1+r)−P where P is the payment per period (e.g. monthly payment). That is the starting balance for the next period which uses the same formula for the next payment. Create a Python program that will allow a user to calculate the amount of a loan after a specified number of monthly payments. Specifically, the program should:

  1. Prompt the user for the initial value of the loan and store the variable as “L_value”
  2. Prompt the user for the interest rate per month and store the value as “i_rate”
  3. Prompt the user for the number of months to calculate and store the value as “n_mo”
  4. Prompt the user for the monthly payment and store as a variable “m_pay”
  5. Calculate the total current value of the loan for a month and store is as “cl_val”
  6. Repeat the calculation for each month specified (n_mo) OR until the loan is paid off (cl_val is less than or equal to 0)
    1. You do NOT have to calculate the final payment amount to get to exactly 0
  7. Print the month number and the total loan amount for each month calculated

Solutions

Expert Solution

Sample outputs:

Program screenshot:

Program code to copy:

# Taking input from user
L_value = float(input("Enter the initial value of the loan: "))
i_rate = float(input("Enter the interest rate per month: "))
n_mo = float(input("Enter the number of months to calculate: "))
m_pay = float(input("Enter the monthly payment: "))

# Calculate the total current value of the loan for a month
cl_val = (L_value * (1 + i_rate/100)) - m_pay

print("")
cur_month = 1 # variable to keep track of current month
# Repeat the calculation for each month specified (n_mo) OR until the
# loan is paid off (cl_val is less than or equal to 0)
while cur_month <= n_mo and cl_val > 0:
print("Month number {}: Total loan amount = {:.2f}".format(cur_month,cl_val))
cur_month += 1
L_value = cl_val
# calculating new loan value
cl_val = (L_value * (1 + i_rate/100)) - m_pay
  
  


Related Solutions

You need to take a loan of $1,500. You have two repayment options: Option 1: Short-term...
You need to take a loan of $1,500. You have two repayment options: Option 1: Short-term 6% interest loan with a term of 1 year. Option 2: 1-year simple interest amortized loan at 6% interest, monthly payments. 1.) Calculate the lump sum payment for plan A. Then calculate the monthly payment for plan B. Explain how you arrived at your answer. You do not need to copy the formulas here; simply explain what formulas you used and how you used...
39. Calculate the value of and interest rate on a loan using the option model and...
39. Calculate the value of and interest rate on a loan using the option model and the following information.             Face value of loan (B) = $500,000             Length of time remaining to loan maturity (t) = 4years             Risk-free rate (i) = 4%             Borrower’s leverage ratio (d) = 60%             Standard deviation of rate of change in the value of the underlying assets (?)= 15% show me the steps with the correct formula please and thank you
The $800 million loan carried a 6% interest rate and had the following repayment of principal...
The $800 million loan carried a 6% interest rate and had the following repayment of principal schedule: Year 1: $132 million Year 2: $32 million Year 3: $57 million Year 4: $82 million Year 5: $82 million Year 6: $415 million What is the present value of the term loan? What would the present value be if the compnay had chosen permanent debt instead of a term loan?
$100,000 loan is made monthly interest-only repayments for 12 years, with the first repayment occurring one...
$100,000 loan is made monthly interest-only repayments for 12 years, with the first repayment occurring one month from today. Then the level annual repayments of $9,456 are made for as long as needed to pay off the remaining balance of the loan, where the first annual repayment is made at the end of year 13. The Annual repayment is made at the end of year 13. The annual effective interest rate is 9.2%. Calculate the total number of repayments to...
Calculate Interest in a Java program. If you know the balance and the annual percentage interest...
Calculate Interest in a Java program. If you know the balance and the annual percentage interest rate, you can compute the interest on the next monthly payment using the following formula: interest = balance * (annualInterestRate/1200) Write a program that reads the balance and the annual percentage interest rate and displays the interest for the next month. Create a scanner Prompt the user to enter a name and create variable for scanner Prompt the user to enter a balance and...
Your friend is asking a $55,000 loan from you with the following repayment schedule: End of...
Your friend is asking a $55,000 loan from you with the following repayment schedule: End of year 1 $ 0 End of year 2 $ 11,000 End of year 3 $ 22,000 End of year 4 $ 33,000 You demand at least 8% return on this loan deal. Answer to the following questions by showing your work using financial calculator keys. (a) Should you enter into this loan based on your PV (or NPV) analysis? (b) What is the expected...
Suppose you have the option to extend a loan to a friend this year for $1000 in exchange for repayment next year of $1100 (the $1100 is the principal plus interest).
Suppose you have the option to extend a loan to a friend this year for $1000 in exchange for repayment next year of $1100 (the $1100 is the principal plus interest). Every year, however, the friend has the option to borrow $1000 again in exchange for $1100 repayment one year later, i.e. the friend can roll over the debt. You know this friend well and know that he will always roll over the debt and will never default.a. Assume neither...
The monthly repayment of a loan for an apartment for student rental is RM 900. An...
The monthly repayment of a loan for an apartment for student rental is RM 900. An additional cost of RM420 on tax and maintenance is also incurred on monthly basis. Given that the rental rate for a similar apartment is RM 500 per month, perform the following. a) A simple economic analysis (without considering the interest rates) on the property investment. [5 marks] b) Then, identify the issues and alternatives available (at least three) based on the outcome of the...
You need a loan of $160,000 to buy a home. Calculate your monthly payments and total...
You need a loan of $160,000 to buy a home. Calculate your monthly payments and total closing costs for each choice below. Choice 1: 30 year fixed rate at 5% with closing costs if $2300 and no points. Choice 2: 30 year fixed rate at 4.5% with closing costs of $2300 and 5 points. What is the monthly payment for choice one? What is the monthly payment for choice two? what is the total closing cost for choice one? what...
I need detailed explanation: Assume you are in repayment on $50,000 in student loans. The terms...
I need detailed explanation: Assume you are in repayment on $50,000 in student loans. The terms of your loan are a 10-year (120 period) repayment term at a 5% annual interest rate (compounded interest). (a) Assuming you make all your monthly payments on time, how much will you pay back in total over the lifetime of this loan? On March 27, 2020, Congress passed the CARES Act, which, among other things, automatically placed all student loans currently in repayment into...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT