For month 1, we can compute the minimum monthly payment by taking 2% of the balance:



Similar documents
Credit Card Loans. Student Worksheet

Paying off a debt. Ethan D. Bolker Maura B. Mast. December 4, 2007

Amortized Loan Example

Relative and Absolute Change Percentages

ROUND(cell or formula, 2)

Loans Practice. Math 107 Worksheet #23

Return on Investment (ROI)

Learn about. How to deposit money. How to make withdrawals and write checks. How to keep track of your money

MAN 4720 STRATEGIC MANAGEMENT AND POLICY FORMULATION FINANCIAL ANALYSIS GUIDE

Solving Compound Interest Problems

Chapter F: Finance. Section F.1-F.4

Pre-Algebra Lecture 6

Interest Rate Derivatives

Activity 1: Using base ten blocks to model operations on decimals

credit card Your Welcome Guide

FINANCIAL ANALYSIS GUIDE

CSCI 1301: Introduction to Computing and Programming Summer 2015 Project 1: Credit Card Pay Off

insight for Importers and Exporters An industry-specific guide for your MYOB software

Dimes to Riches Money Management for Teens in Grades 7-12

ALGEBRA I (Common Core)

Finance. Simple Interest Formula: I = P rt where I is the interest, P is the principal, r is the rate, and t is the time in years.

Introduction to Macroeconomics TOPIC 2: The Goods Market

DIVISION OF DECIMALS We then we multiply by the

16 21 Linear vs. Exponential.notebook May 14, LT 1c: I can compare linear vs. exponential change.

Example 1: Suppose the demand function is p = 50 2q, and the supply function is p = q. a) Find the equilibrium point b) Sketch a graph

Real Estate Investment Newsletter November 2003

Westpac. Home Loans. Enjoy a place of your own with your. Westpac. Home Loan

14:440:127 Introduction to Computers for Engineers. Notes for Lecture 06

Rewards. Setting Up, Implementing, & Redeeming Rewards

This Unit: Floating Point Arithmetic. CIS 371 Computer Organization and Design. Readings. Floating Point (FP) Numbers

Finance 197. Simple One-time Interest

Chapter 7 Notes - Inference for Single Samples. You know already for a large sample, you can invoke the CLT so:

credit card Your Welcome Guide

Lesson 4 Annuities: The Mathematics of Regular Payments

Annual leave and bank holidays policy

Further information about your mortgage

FastPhone User Guide. Banking at your finger tips.

Drawing a histogram using Excel

Time Billing. Chapter 1: Time Billing Activities Overview 563. Chapter 2: Creating activities 569. Chapter 3: Changing activities 574

Westpac. Home Loans. Enjoy a place of your own with your. Westpac. Home Loan

Evaluating Your Student Debt Situation

SEEM 2440A/B Engineering Economics First term, Midterm Examination

Python Lists and Loops

MAS.836 HOW TO BIAS AN OP-AMP

Savings and Bank Accounts

Numerator Denominator

Representing Decimals (pages )

Tax Planning & Personal Investment. Customer Value

HOME EQUITY LINES OF CREDIT

LESSON 5 - DECIMALS INTRODUCTION

Finance CHAPTER OUTLINE. 5.1 Interest 5.2 Compound Interest 5.3 Annuities; Sinking Funds 5.4 Present Value of an Annuity; Amortization

Federal Income Tax Information January 29, 2016 Page Federal Income Tax Withholding Information - PERCENTAGE METHOD

Math Refresher. Book #2. Workers Opportunities Resources Knowledge

Unit 7 The Number System: Multiplying and Dividing Integers

Gas Money Gas isn t free. In fact, it s one of the largest expenses many people have each month.

FRACTIONS COMMON MISTAKES

Example. L.N. Stout () Problems on annuities 1 / 14

CHAPTER 1: SPREADSHEET BASICS. AMZN Stock Prices Date Price

Lesson 5: Savvy Savers

Adding & Subtracting Integers

140 SU 3: Profitability Analysis and Analytical Issues

Midterm 1 Practice Problems

Workbook. Numerical Reasoning tests. Careers Service

Finance 3130 Sample Exam 1B Spring 2012

Math 1526 Consumer and Producer Surplus

Preparing cash budgets

Estimating a market model: Step-by-step Prepared by Pamela Peterson Drake Florida Atlantic University

Workbook. Numerical Reasoning tests. Careers Service

10. Time Value of Money 2: Inflation, Real Returns, Annuities, and Amortized Loans

Accuplacer Arithmetic Study Guide

1. Annuity a sequence of payments, each made at equally spaced time intervals.

Introduction to the Hewlett-Packard (HP) 10BII Calculator and Review of Mortgage Finance Calculations

Marginal cost. Average cost. Marginal revenue

Lecture 4: Binary. CS442: Great Insights in Computer Science Michael L. Littman, Spring I-Before-E, Continued

CHAPTER 1. Compound Interest

CS101 Lecture 24: Thinking in Python: Input and Output Variables and Arithmetic. Aaron Stevens 28 March Overview/Questions

Computer Science 217

Data Structures. Algorithm Performance and Big O Analysis

Debt consolidation A step-by-step guide

Combined Business Loan

Introduction to Python

Jade Education Award Story: Smart Loan Strategies Page 1. This is Jade.

Important Financial Concepts

Similar matrices and Jordan form

TEST 2 STUDY GUIDE. 1. Consider the data shown below.

Normal distributions in SPSS

A guide to terms and conditions

PAYCHEX, INC. BASIC BUSINESS MATH TRAINING MODULE

Homework Solutions - Lecture 2

Provided by: Sales Scripts

Chapter 5. Decimals. Use the calculator.

Recall the process used for adding decimal numbers. 1. Place the numbers to be added in vertical format, aligning the decimal points.

Basic Components of an LP:

Use and Care Guide. FCC Requirements. Smart Toys for Today s Kids!

Section one: Interest on and repayment of educational loans and loss of rights

YOUR PIPE RENEWAL CIP, PART 2: THE SANDS OF TIME

Computer Networks By Bahaa Q. Al-Mussawi Subnetting Basics Reduced network traffic Optimized network performance Simplified management

CHAPTER 5 INTRODUCTION TO VALUATION: THE TIME VALUE OF MONEY

Fractions. If the top and bottom numbers of a fraction are the same then you have a whole one.

Transcription:

Problem Set 1 Handed out: Lecture 2. Due: 11:59pm, Lecture 4. Introduction This problem set will introduce you to using control flow in Python and formulating a computational solution to a problem. You will design and write three simple Python programs, test them, and hand them in. Be sure to read this problem set thoroughly. Paying Off Credit Card Debt Each month, a credit card statement will come with the option for you to pay a minimum amount of your charge, usually 2% of the balance due. However, the credit card company earns money by charging interest on the balance that you don t pay. So even if you pay credit card payments on time, interest is still accruing on the outstanding balance. Say you ve made a $5,000 purchase on a credit card with 18% annual interest rate and 2% minimum monthly payment rate. After a year, how much is the remaining balance? Use the following equations. Minimum monthly payment = Minimum monthly payment rate x Balance (Minimum monthly payment gets split into interest paid and principal paid) Interest Paid = Annual interest rate / 12 months x Balance Principal paid = Minimum monthly payment Interest paid Remaining balance = Balance Principal paid For month 1, we can compute the minimum monthly payment by taking 2% of the balance: Minimum monthly payment =.02 x $5000.0 = $100.0 We can t simply deduct this from the balance because there is compounding interest. Of this $100 monthly payment, compute how much will go to paying off interest and how much will go to paying off the principal. Remember that it s the annual interest rate that is given, so we need to divide it by 12 to get the monthly interest rate. Interest paid =.18/12.0 x $5000.0 = $75.0 Principal paid = $100.0 $75.0 = $25 The remaining balance at the end of the first month will be the principal paid this month subtracted from the balance at the start of the month. Remaining balance = $5000.0 $25.0 = $4975.0

For month 2, we repeat the same steps: Minimum monthly payment =.02 x $4975.0 = $99.50 Interest Paid =.18/12.0 x $4975.0 = $74.63 Principal Paid = $99.50 $74.63 = $24.87 Remaining Balance = $4975.0 $24.87 = $4950.13 After 12 months, the total amount paid is $1167.55, leaving an outstanding balance of $4708.10. Pretty depressing! Paying the Minimum Problem 1 Write a program to calculate the credit card balance after one year if a person only pays the minimum monthly payment required by the credit card company each month. Use raw_input() to ask for the following three floating point numbers: 1. the outstanding balance on the credit card 2. annual interest rate 3. minimum monthly payment rate For each month, print the minimum monthly payment, remaining balance, principle paid in the format shown in the test cases below. All numbers should be rounded to the nearest penny. Finally, print the result, which should include the total amount paid that year and the remaining balance. Test Case 1 Enter the outstanding balance on your credit card: 4800 Enter the annual credit card interest rate as a decimal:.2 Enter the minimum monthly payment rate as a decimal:.02 Month: 1 Minimum monthly payment: $96.0 Principle paid: $16.0 Remaining balance: $4784.0 Month: 2 Minimum monthly payment: $95.68 Principle paid: $15.95 Remaining balance: $4768.05 Month: 3 Minimum monthly payment: $95.36 Principle paid: $15.89 Remaining balance: $4752.16

Month: 4 Minimum monthly payment: $95.04 Principle paid: $15.84 Remaining balance: $4736.32 Month: 5 Minimum monthly payment: $94.73 Principle paid: $15.79 Remaining balance: $4720.53 Month: 6 Minimum monthly payment: $94.41 Principle paid: $15.73 Remaining balance: $4704.8 Month: 7 Minimum monthly payment: $94.1 Principle paid: $15.69 Remaining balance: $4689.11 Month: 8 Minimum monthly payment: $93.78 Principle paid: $15.63 Remaining balance: $4673.48 Month: 9 Minimum monthly payment: $93.47 Principle paid: $15.58 Remaining balance: $4657.9 Month: 10 Minimum monthly payment: $93.16 Principle paid: $15.53 Remaining balance: $4642.37 Month: 11 Minimum monthly payment: $92.85 Principle paid: $15.48 Remaining balance: $4626.89 Month: 12 Minimum monthly payment: $92.54 Principle paid: $15.43 Remaining balance: $4611.46 Total amount paid: $1131.12 Remaining balance: $4611.46 Test Case 2 In recent years, many credit card corporations tightened restrictions by raising their minimum monthly payment rate to 4%. As illustrated in the second test case below, people will be able to pay less interest over the years and get out of debt faster.

Enter the outstanding balance on your credit card: 4800 Enter the annual credit card interest rate as a decimal:.2 Enter the minimum monthly payment rate as a decimal:.04 Month: 1 Minimum monthly payment: $192.0 Principle paid: $112.0 Remaining balance: $4688.0 Month: 2 Minimum monthly payment: $187.52 Principle paid: $109.39 Remaining balance: $4578.61 Month: 3 Minimum monthly payment: $183.14 Principle paid: $106.83 Remaining balance: $4471.78 Month: 4 Minimum monthly payment: $178.87 Principle paid: $104.34 Remaining balance: $4367.44 Month: 5 Minimum monthly payment: $174.7 Principle paid: $101.91 Remaining balance: $4265.53 Month: 6 Minimum monthly payment: $170.62 Principle paid: $99.53 Remaining balance: $4166.0 Month: 7 Minimum monthly payment: $166.64 Principle paid: $97.21 Remaining balance: $4068.79 Month: 8 Minimum monthly payment: $162.75 Principle paid: $94.94 Remaining balance: $3973.85 Month: 9 Minimum monthly payment: $158.95 Principle paid: $92.72 Remaining balance: $3881.13 Month: 10 Minimum monthly payment: $155.25 Principle paid: $90.56 Remaining balance: $3790.57 Month: 11 Minimum monthly payment: $151.62

Principle paid: $88.44 Remaining balance: $3702.13 Month: 12 Minimum monthly payment: $148.09 Principle paid: $86.39 Remaining balance: $3615.74 Total amount paid: $2030.15 Remaining balance: $3615.74 Hints Use the round function. To help you get started, here is a rough outline of the stages you should probably follow in writing your code: Retrieve user input. Initialize some state variables. Remember to find the monthly interest rate from the annual interest rate taken in as input. For each month: o Compute the new balance. This requires computing the minimum monthly payment and figuring out how much will be paid to interest and how much will be paid to the principal. o Update the outstanding balance according to how much principal was paid off. o Output the minimum monthly payment and the remaining balance. o Keep track of the total amount of paid over all the past months so far. Print out the result statement with the total amount paid and the remaining balance. Use these ideas to guide the creation of your code. Paying Debt Off In a Year Problem 2 Now write a program that calculates the minimum fixed monthly payment needed in order pay off a credit card balance within 12 months. We will not be dealing with a minimum monthly payment rate. Take as raw_input() the following floating point numbers: 1. the outstanding balance on the credit card 2. annual interest rate as a decimal

Print out the fixed minimum monthly payment, number of months (at most 12 and possibly less than 12) it takes to pay off the debt, and the balance (likely to be a negative number). Assume that the interest is compounded monthly according to the balance at the start of the month (before the payment for that month is made). The monthly payment must be a multiple of $10 and is the same for all months. Notice that it is possible for the balance to become negative using this payment scheme. In short: Monthly interest rate = Annual interest rate / 12.0 Updated balance each month = Previous balance * (1 + Monthly interest rate) Minimum monthly payment Test Case 1 Enter the outstanding balance on your credit card: 1200 Enter the annual credit card interest rate as a decimal:.18 Monthly payment to pay off debt in 1 year: 120 Number of months needed: 11 Balance: -10.05 Test Case 2 Enter the outstanding balance on your credit card: 32000 Enter the annual credit card interest rate as a decimal:.2 Monthly payment to pay off debt in 1 year: 2970 Number of months needed: 12 Balance: -74.98 Hints Start at $10 payments per month and calculate whether the balance will be paid off (taking into account the interest accrued each month). If $10 monthly payments are insufficient to pay off the debt within a year, increase the monthly payment by $10 and repeat. Using Bisection Search to Make the Program Faster You ll notice that in problem 2, your monthly payment had to be a multiple of $10. Why did we make it that way? In a separate file, you can try changing the code so that the payment can be any dollar and cent amount (in other words, the monthly payment is a multiple of $0.01). Does

your code still work? It should, but you may notice that your code runs more slowly, especially in cases with very large balances and interest rates. How can we make this program faster? We can use bisection search (to be covered in lecture 3)! We are searching for the smallest monthly payment such that we can pay off the debt within a year. What is a reasonable lower bound for this value? We can say $0, 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. 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 would be one-twelfth of the balance, after having its interest compounded monthly for an entire year. In short: Monthly payment lower bound = Balance / 12.0 Monthly payment upper bound = (Balance * (1 + (Annual interest rate / 12.0)) ** 12.0) / 12.0 Problem 3 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. Produce the output in the same format as you did in problem 2. Test Case 1 Enter the outstanding balance on your credit card: 320000 Enter the annual credit card interest rate as a decimal:.2 Monthly payment to pay off debt in 1 year: 29643.05 Number of months needed: 12 Balance: -0.1 Test Case 2 Enter the outstanding balance on your credit card: 999999 Enter the annual credit card interest rate as a decimal:.18

Monthly payment to pay off debt in 1 year: 91679.91 Number of months needed: 12 Balance: -0.12 Hand-In Procedure 1. Save Save your solution to Problem 1 as ps1a.py, Problem 2 as ps1b.py, and Problem 3 as ps1c.py. Do not ignore this step or save your files with a different name. 2. Time and Collaboration Info At the start of each file, in a comment, write down the number of hours (roughly) you spent on the problems in that part, and the names of the people you collaborated with. For example: # Problem Set 1 # Name: Jane Lee # Collaborators: John Doe # Time Spent: 3:30 # your code goes here

MIT OpenCourseWare http://ocw.mit.edu 6.00SC Introduction to Computer Science and Programming Spring 2011 For information about citing these materials or our Terms of Use, visit: http://ocw.mit.edu/terms.