Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

3) Part C: Choosing an Interest Rate In Part A and B, you explored how (1) the percentage of your salary saved each month and

image text in transcribed

3) Part C: Choosing an Interest Rate In Part A and B, you explored how (1) the percentage of your salary saved each month and (2) a semi-annual raise affects how long it takes to save for a down payment given a fixed rate of return, r. In Part C, we will have a fixed initial amount and the ability to choose a value for the rate of return, r. Given an initial deposit amount, our goal is to find the lowest rate of return that enables us to save enough money for the down payment in 3 years. User Inputs Cast the user input as a float in the beginning of your program. 1. The initial amount in your savings account initial amount) Writing the Program Write a program to calculate what r should be in order to reach your goal of a sufficient down payment in 3 years, given an initial_amount. To simplify things, assume: 1. The cost of the house that you are saving for is $750,000 2. The down payment is 25% of the cost of the house Use the following formula for compounded interest in order to calculate the predicted savings amount given a rate of return r, an initial_amount, and number_of_months: current_savings = initial_amount *(1+r/12) number_of_months You will use bisection search to determine the lowest rate of return, r, that is needed to achieve a down payment on a $750K house in 36 months. Since hitting this exact amount is a bit of a challenge, we only require that your savings be within $100 of the required down payment. For example, if the down payment is $1000, the total amount saved should be between $900 and $1100 (exclusive). Your bisection search should update the value of r until it represents the lowest rate of return that allows you to save enough for the down payment in 3 years. r should be a float (e.g. 0.0704 for 7.04%). Assume that r lies somewhere between 0% and 100% (inclusive). The variable steps should reflect the number of steps your bisection search took to get the best r value (i.e. steps should equal the number of times that you bisect the testing interval). Notes There may be multiple rates of return that yield a savings amount that is within $100 of the required down payment on a $750,000 house. The grader will accept any of these values of r. If the initial deposit amount is greater than or equal to the required down payment - $100, then the best savings rate is 0.0. If it is not possible to save within $100 of the required down payment in 3 years given the initial deposit and a rate of return between 0% and 100%, r should be assigned the value None. o Note: the value None is different than "None". The former is Python's version of a null value, and the latter is a string. Depending on your stopping condition and how you compute the amount saved for your bisection search, your number of steps may vary slightly from the example test cases. Running ps1_tester.py should give you a good indication of whether or not your number of steps is close enough to the expected solution. If a test is taking a long time, you might have an infinite loop! Check your stopping condition. Your program should print in the same format as the test cases below. 3) Part C: Choosing an Interest Rate In Part A and B, you explored how (1) the percentage of your salary saved each month and (2) a semi-annual raise affects how long it takes to save for a down payment given a fixed rate of return, r. In Part C, we will have a fixed initial amount and the ability to choose a value for the rate of return, r. Given an initial deposit amount, our goal is to find the lowest rate of return that enables us to save enough money for the down payment in 3 years. User Inputs Cast the user input as a float in the beginning of your program. 1. The initial amount in your savings account initial amount) Writing the Program Write a program to calculate what r should be in order to reach your goal of a sufficient down payment in 3 years, given an initial_amount. To simplify things, assume: 1. The cost of the house that you are saving for is $750,000 2. The down payment is 25% of the cost of the house Use the following formula for compounded interest in order to calculate the predicted savings amount given a rate of return r, an initial_amount, and number_of_months: current_savings = initial_amount *(1+r/12) number_of_months You will use bisection search to determine the lowest rate of return, r, that is needed to achieve a down payment on a $750K house in 36 months. Since hitting this exact amount is a bit of a challenge, we only require that your savings be within $100 of the required down payment. For example, if the down payment is $1000, the total amount saved should be between $900 and $1100 (exclusive). Your bisection search should update the value of r until it represents the lowest rate of return that allows you to save enough for the down payment in 3 years. r should be a float (e.g. 0.0704 for 7.04%). Assume that r lies somewhere between 0% and 100% (inclusive). The variable steps should reflect the number of steps your bisection search took to get the best r value (i.e. steps should equal the number of times that you bisect the testing interval). Notes There may be multiple rates of return that yield a savings amount that is within $100 of the required down payment on a $750,000 house. The grader will accept any of these values of r. If the initial deposit amount is greater than or equal to the required down payment - $100, then the best savings rate is 0.0. If it is not possible to save within $100 of the required down payment in 3 years given the initial deposit and a rate of return between 0% and 100%, r should be assigned the value None. o Note: the value None is different than "None". The former is Python's version of a null value, and the latter is a string. Depending on your stopping condition and how you compute the amount saved for your bisection search, your number of steps may vary slightly from the example test cases. Running ps1_tester.py should give you a good indication of whether or not your number of steps is close enough to the expected solution. If a test is taking a long time, you might have an infinite loop! Check your stopping condition. Your program should print in the same format as the test cases below

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions