In: Computer Science
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 also the total paid (initial loan plus the interest). You do not need to output the monthly interest paid and the remaining debt. Your output should look like the following…(it may differ, if you use GUIs).
Program screenshots:
Sample Output:
Code to Copy:
# kindly use python 3
# kindly indent the code as given in above screenshot
# prompt the user to enter the details.
prin = float(input("Enter the loan amount :"))
r = float(input("Enter the interest rate :"))
# assign value.
initial_prin=prin
# initialize variable
emi = prin*(5/100)
month = 0
t_interest = 0
# start the while loop
while(True):
# check the condition.
if(prin>0):
# calculate interest
interest = prin*(1.5/100.0)
# add interest
t_interest += interest
# calculate decreased amount
dec = emi - interest
prin = prin - dec
# update month
month += 1
else:
break;
# display results
print()
print("Loan amount : $",initial_prin)
print("Interest rate : ",r)
print("Monthly payment : $",round(emi,2))
print("Final payment : $",round(prin+dec,2))
print("Life of loan (Months): ",month)
print("Total Interest paid : $",round(t_interest,2))
print("Total paid at the end of loan: $",round(initial_prin+t_interest,2))