import math
annual_salary = int(input('Enter your annual salary:'))
portion_salary = float(input('Enter the percent of your salary to save, as a decimal:'))
total_cost = int(input('Enter the cost of your dream home:'))
semi_annual_raise= float(input('Enter the semiannual raise, as a decimal:'))
portion_down_payment = 0.25 * total_cost
month = 1
r = 0.04
portion_saved = 0
current_savings = portion_salary * annual_salary /12
while current_savings < portion_down_payment:
if month % 6 == 0:
annual_salary = annual_salary * (1 + semi_annual_raise)
portion_saved = portion_salary * annual_salary / 12
current_savings = current_savings * r / 12 + portion_saved + current_savings
month += 1
print('Number of months: ', math.ceil(month))
MIT 6.0001 ps1 b
最新推荐文章于 2021-05-18 23:05:58 发布