Python code only. Test Case 1: balance = 320000 Test Case 2: balance = 999999 an
ID: 3850497 • Letter: P
Question
Python code only.
Test Case 1: balance = 320000
Test Case 2: balance = 999999
annualInterestRate = 0.18
The following variables contain values as described below: 1. balance the outstanding balance on the credit card 2. annual InterestRate annual interest rate as a decima To recap the problem: we are searching for the smallest monthly payment such that we can pay off the entire balance within a year. What is a reasonable lower bound for this payment value? $0 is the obvious anwer, but you can do better than that. If there was no interest, the debt can be paid off by monthly payments of one-twelfth of the original balance, so we must pay at least this much every month. One-twelfth of the original balance is a good lower bound What is a good upper bound? Imagine that instead of paying monthly, we paid off the entire balance at the end of the year. What we ultimately pay must be greater than what we would've paid in monthly installments, because the interest was compounded on the balance we didn't pay off each month. So a good upper bound for the monthly payment would be one-twelfth of the balance, after having its interest compounded monthly for an entire year. In short: Monthly interest rate -(Annual interest rate) 12.0 Monthly payment lower bound Balance 12 Monthly payment upper bound Balance x (1 Monthly interest rate) 12 12.0Explanation / Answer
import math
amt=int(input("Enter the amount")) #acccepting user input
intr=int(input("Enter the interest"))
monthly_intr=intr/12.0 #calculating monthly interest
monthly_pay_lower=amt/12 #calculating monthly lower pay
j=(1+monthly_intr)
k=math.pow(j,12)
monthly_pay_upper=(amt*j)/12.0 #calculating monthly upper pay
print ("Amount is",amt) #printing the details
print("Annual interest is",intr)
print("Monthly interest is",monthly_intr)
print("Monthly Lower Bound is",monthly_pay_lower)
print("Monthly Upper Bound is",monthly_pay_upper)
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.