Question

In: Computer Science

Using Python write an application that will calculate a loan payment. To complete this, you are...

Using Python write an application that will calculate a loan payment. To complete this, you are required to write 2 functions, LoanPayment and InterestOnlyLoanPayment, as well as a test application that calls each of the functions to get the payment amount based on parameters supplied to the functions. The test application should output both the loan payment and the interest-only loan payment based on input values from the user.

The LoanPayment function is defined as follows:

Payment = Loan amount / Discount factor

The discount factor is {[(1 + i)^n] - 1} / [i(1 + i)^n], where you have the following:

  • n = Payments per year × Number of years
  • i = Annual interest rate / Payments per year

Take for example the following:

D = {[(1 + 0.005)^360] – 1} / [0.005(1 + 0.005)^360] = 166.7916, where n = 12 × 30 and i = 0.06 / 12.

Loan payment = $250,000 / 166.7916 = $1,498.88

The InterestOnlyLoanPayment is defined as follows:

Interest-only payment = Loan amount × (Annual interest rate / 12)

Take for example the following:

Interest-only payment = $250,000 × (0.06 / 12) = $1,250

The test application interaction should be something like the following:

  • Enter loan amount: $250,000
  • Enter duration of loan: 30
  • Enter interest rate: 6
  • Interest only payment: $1,250
  • Principle or interest payment: $1,498.88

Solutions

Expert Solution

def LoanPayment(loan_amount,n,i):

    disc_factor=(((1+i)**n)-1)/(i*(1+i)**n)#The discount factor is {[(1 + i)^n] - 1} / [i(1 + i)^n],
    loan_payment=loan_amount/disc_factor #loan_payment is calculated
    return loan_payment #return loan_payment
  
def InterestOnlyLoanPayment(loan_amount,i):
    interest_only_payment=loan_amount*i # Interest-only payment = Loan amount × (Annual interest rate / 12)
    return interest_only_payment


loan_amount=int(input("Enter loan amount: ")) #input loan_amount
numb_of_years=int(input("Enter duration of loan: ")) # input number of years
rate_of_interest=int(input("Enter interest rate: ")) #input rate of interest
n=12*numb_of_years
i=rate_of_interest*0.01/12
loan_payment=LoanPayment(loan_amount,n,i)
interest_only_payment=InterestOnlyLoanPayment(loan_amount,i)
print("Principle or interest payment: ",loan_payment)   # OUTPUT LOAN_PAYMENT
print("Interest only payment: ",interest_only_payment) # OUTPUT INTEREST ONLY PAYMENT

def LoanPayment(loan_amount,n,i):

    disc_factor=(((1+i)**n)-1)/(i*(1+i)**n) #The discount factor is {[(1 + i)^n] - 1} / [i(1 + i)^n], 
    loan_payment=loan_amount/disc_factor  #loan_payment is calculated
    return loan_payment  #return loan_payment
    
def InterestOnlyLoanPayment(loan_amount,i):
    interest_only_payment=loan_amount*i # Interest-only payment = Loan amount × (Annual interest rate / 12)
    return interest_only_payment


loan_amount=int(input("Enter loan amount: "))  #input loan_amount
numb_of_years=int(input("Enter duration of loan: ")) # input number of years
rate_of_interest=int(input("Enter interest rate: ")) #input rate of interest
n=12*numb_of_years
i=rate_of_interest*0.01/12
loan_payment=LoanPayment(loan_amount,n,i)
interest_only_payment=InterestOnlyLoanPayment(loan_amount,i)
print("Principle or interest payment: ",loan_payment)   # OUTPUT LOAN_PAYMENT
print("Interest only payment: ",interest_only_payment)  # OUTPUT INTEREST ONLY PAYMENT

Related Solutions

Using the ENGR 315 Automobile Loan Payment Calculator posted, calculate the monthly payment required for a...
Using the ENGR 315 Automobile Loan Payment Calculator posted, calculate the monthly payment required for a 60-month new automobile loan made by the lender at 4.74% annual percentage rate (APR) if the car buyer borrowed $35,742. Save the resulting Excel spreadsheet file, as a PDF, presenting your payment calculations
Write a Java application for a gas station to calculate the total payment for customer. Your...
Write a Java application for a gas station to calculate the total payment for customer. Your program should display a menu and get customer’s input: **************************** Welcome to XYZ gas station! Select type of gas (enter R, P, S) Regular - R. plus - P. Super -S: **************************** Enter the amount of gas in gallons: In your code, define regular price: $2.45, plus: $2.65, super $2.95 as constant. Use 7% as sale tax. Calculate gas subtotal = sale price *...
Calculate the monthly payment for loan amount of $350,000 using the following parameters: • 20 Year...
Calculate the monthly payment for loan amount of $350,000 using the following parameters: • 20 Year Loan, fully amortizing • Interest Rate of 3.29% What is the monthly payment amount (rounded to the nearest dollar)? a. $2,466 b. $2,276 c. $1,992 d. $1,713 Calculate the monthly payment for loan amount of $150,000 using the following parameters: • 30 Year Loan, fully amortizing • Interest Rate of 7.00% What is the monthly payment amount (rounded to the nearest dollar)? a. $...
Calculate the monthly payment for loan amount of $250,000 using the following parameters: • 30 Year...
Calculate the monthly payment for loan amount of $250,000 using the following parameters: • 30 Year Loan, fully amortizing • Interest Rate of 3.50% What is the monthly payment amount (rounded to the nearest dollar)? a. $1,123 b. $1,321 c. $1,572 d. $1,252 Calculate the monthly payment for loan amount of $250,000 using the following parameters: • 15 Year Loan, fully amortizing • Interest Rate of 3.09% What is the monthly payment amount (rounded to the nearest dollar)? a. $1,398...
Using Python, write a simple application that takes user input of plaintext and key, and encrypt...
Using Python, write a simple application that takes user input of plaintext and key, and encrypt the plaintext with Vigenere Cipher. The application should then print out the plaintext and the ciphertext.
Complete the following in syntactically correct Python code. Write a program, using a for loop, that...
Complete the following in syntactically correct Python code. Write a program, using a for loop, that calculates the amount of money a person would earn over a period of time if his or her salary is 1 penny for the first day, 2 pennies for the second day, 4 pennies for the third day, and continues to double each day. 1.      The program should ask the user for the number of days the employee worked. 2.      Display a table showing the salary...
Using steps.py in this repository for a starter file, write a Python program to calculate average...
Using steps.py in this repository for a starter file, write a Python program to calculate average number of steps per month for a year. The input file (which you will read from the command line, see the sample program on how to read command line arguments in this repository) contains the number of steps (integer) a person took each day for 1 year, starting January 1. Each line of input contains a single number. Assume this is NOT a leap...
Write a Python Version 3 program that will ask you the loan amount and the interest...
Write a Python Version 3 program that will ask you the loan amount and the interest rate. Then the program will tell you - The monthly payment, How many months it will take you to pay off the loan, The total amount of interest paid over the life of the loan. Program should also indicate the final payment as in many cases the final payment at the end of the loan would not be exactly the normal monthly payment and...
Calculate the table factor, the finance charge, and the monthly payment (in $) for the loan...
Calculate the table factor, the finance charge, and the monthly payment (in $) for the loan by using the APR table, Table 13-1. (Round your answers to the nearest cent.) Amount Financed Number of Payments APR Table Factor Finance Charge Monthly Payment $9,400 36 13% $ $ $
Write a complete and syntactically correct Python program to solve the following problem: You are the...
Write a complete and syntactically correct Python program to solve the following problem: You are the payroll manager for SoftwarePirates Inc. You have been charged with writing a package that calculates the monthly paycheck for the salespeople. Salespeople at SoftwarePirates get paid a base salary of $2000 per month. Beyond the base salary, each salesperson earns commission on the following scale: Sales Commission Rate Bonus <$10000 0% 0 $10000 – $100,000 2% 0 $100,001 - $500,000 15% $1000 $500,001 -...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT