Question

question: Write a program that uses these bounds and bisection search (for more info check out...

question: Write a program that uses these bounds and bisection search (for more info check out the Wikipedia page here) to find the smallest monthly payment to the cent (no more multiples of $10) such that we can pay off the debt within a year. Try it out with large inputs, and notice how fast it is.

Output Phython: Enter the outstanding balance on your credit card: 320000 Enter the annual credit card interest rate as a decimal: .2 RESULT Monthly payment to pay off debt in 1 year: 29643.05 Number of months needed: 12 Balance: -0.1

0 0
Add a comment Improve this question Transcribed image text
Answer #1

# In python 3

balance = float(input("Enter the outstanding balance on your credit card: ")) # Asking the user to input outstanding balance
  
annualInterestRate = float(input("Enter the annual interest rate as a decimal: ")) # Asking the user to input annual interest rate
newbalance = balance # Storing the balance in newbalance to use in calculations

monthlyInterestRate = annualInterestRate/12.0 # Calculating the monthly interest rate

lowerbound = newbalance/12.0 # Lower bound of the monthlyPayment is balance/12.0

upperbound = (newbalance *(1+monthlyInterestRate)**12)/12.0 # Upper bound of the monthlyPayment is calculated using the compound interest formula
#The minimumMonthlyPay lies somewhere in between the lower bounbd and the upper bound. We need to search for it

minimumMonthlyPay = (lowerbound + upperbound)/2.0 # We start searching for the minimumMonthlyPay using the average of lower and upper bounds just like in binary search

i = 1 # Inintializing the looping variable

while(i <= 12):
monthlyUnpaidBal = newbalance - minimumMonthlyPay # Unpaid balance for each month
newbalance = monthlyUnpaidBal + monthlyInterestRate * monthlyUnpaidBal #New balance because of the interest rate
i += 1
  
if(i == 13 and round(newbalance,2) > 0.00): #Checking whether the minimum monthly pay is greater than the average of lower and upperbounds
# if so we search between average and upper bound
i = 1
lowerbound = minimumMonthlyPay

minimumMonthlyPay = (lowerbound + upperbound)/2.0
newbalance = balance
  
elif(i == 13 and round(newbalance,2) <0.00 ): # Checking if the minimum monthlypay is lesser than average of lower and upper bounds
#if so we search between lowerbound and average
i = 1
upperbound = minimumMonthlyPay
minimumMonthlyPay = (lowerbound + upperbound)/2.0
newbalance = balance   
  
  
#Printing out the minimumMonthlyPay   
print ("Monthly Payment to pay off debt in 1 year:", round(minimumMonthlyPay,2))

Add a comment
Know the answer?
Add Answer to:
question: Write a program that uses these bounds and bisection search (for more info check out...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Question Help 0 A new employee charged $8490 on his credit card to relocate for his...

    Question Help 0 A new employee charged $8490 on his credit card to relocate for his first job. After noticing that the interest rate for his balance was 15% compounded monthly, he stopped charging on that account. He wishes to pay off his balance in 3 years using automatic payments sent at the end of each month. a. What monthly payment must he make to pay off the account at the end of 3 years? b. How much total interest...

  • Problem 5.37 (Paying off Credit Cards) Question 20 of 20 Check My Work (3 remaining) eBook...

    Problem 5.37 (Paying off Credit Cards) Question 20 of 20 Check My Work (3 remaining) eBook Simon recently received a credit card with a 15% nominal interest rate. With the card, he purchased an Apple iPhone 7 for $384.88. The minimum payment on the card is only $10 per month a. If Simon makes the minimum monthly payment and makes no other charges, how many months will it be before he pays off the card? Do not round Intermediate calculations....

  • Your program will ask the user to enter the amount of money they want to borrow,...

    Your program will ask the user to enter the amount of money they want to borrow, the interest rate, and the monthly payment amount. Your program will then determine how many months it will take to pay off that loan, what the final payment amount will be, and how much interest was paid over that time. If the monthly payment amount isn't high enough to pay off more than one month's interest, your program should notify the user what the...

  • Please help me! I am very lost in trying to figure all of this out! 1....

    Please help me! I am very lost in trying to figure all of this out! 1. Suppose that 10 years ago you bought a home for $150,000, paying 10% as a down payment, and financing the rest at 8% interest for 30 years. How much money did you pay as your down payment? 2. How much money was your existing mortgage (loan) for? 3. What is your current monthly payment on your existing mortgage? Note: Carry at least 4 decimal...

  • This C++ Program should be written in visual studio 2017 You are to write a program...

    This C++ Program should be written in visual studio 2017 You are to write a program that can do two things: it will help users see how long it will take to achieve a certain investment goal given an annual investment amount and an annual rate of return; also, it will help them see how long it will take to pay off a loan given a principal amount, an annual payment amount and an annual interest rate. When the user...

  • The following question will test your skills of time value of money techniques applied to credit...

    The following question will test your skills of time value of money techniques applied to credit cards. Suppose you owe $10,000 on a credit card. The credit card has an APR1 of 18%. In the following questions we will assume you make NO additional charges on your credit card. a. If you wish to pay of the balance in 5 years, how much should you pay monthly? b. If you make the required payments calculated in a., at the end...

  • in al More Info For all payroll calculations, use the following tax rates and round amounts...

    in al More Info For all payroll calculations, use the following tax rates and round amounts to the nearest cent: Employee: OASDI: 6.2% on first $118,500 earned; Medicare: 1.45% up to $200,000, 2.35% on earnings above $200,000. Employer: OASDI: 6.2% on first $118,500 earned; Medicare: 1.45% on all earnings; FUTA: 0.6% on first $7,000 earned; SUTA: 5.4% on first $7,000 earned. Print Done Louis Welch is general manager of Moonwalk Salons. During 2018, Welch worked for the company all year...

  • Your friend Sue has asked you to help her out as she is developing her financial plan. Help her come up with a plan for...

    Your friend Sue has asked you to help her out as she is developing her financial plan. Help her come up with a plan for her finances and how she can set herself up for financial success! She has an after tax income of $48,000 and budgets $30,000 for necessary expenses. This leaves $18,000 to spend on debt and savings annually. (Assume all annuity payments are in the form of ordinary annuities.) Part A: Debt Sue has a current balance...

  • Lab 1: Check out my wheels! You want to purchase a car and need a loan...

    Lab 1: Check out my wheels! You want to purchase a car and need a loan of $15,000. Check the current interest rates online for 2 year car loans and 5 year car loans. Paste a link to the website that lists the interest rate. Create amortization tables for both loans. (For the 5 year loan, you will need to extend the table from the example.) What are the total payments for each loan? (You can sum the payments or...

  • Need help figuring out the GROSS INCOME please Jamie Lee Jackson, age 26, is in her...

    Need help figuring out the GROSS INCOME please Jamie Lee Jackson, age 26, is in her last semester of college and is waiting for graduation day that is just around the corner! It is the time of year again when Jamie Lee must file her annual federal income taxes. Last year, she received an increase in salary from the bakery, which brought her gross monthly earnings to $2,800, and also opened up an IRA, to which she contributed $200 last...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT