0

Help me please! T.T

1. Have the user input a semi-annual salary raise ​semi_annual_raise​ (as a decimal percentage). 2. After the 6​t​h​ ​month, increase your salary by that percentage. Do the same after the 12​t​h month, the 18​​th​ ​month, and so on. Write a program to calculate how many months it will take you save up enough money for a down payment. LIke before, assume that your investments earn a return of ​r​ = 0.04 (or 4%) and the required down payment percentage is 0.25 (or 25%). Have the user enter the following variables: 1. The starting annual salary (annual_salary) 2. The percentage of salary to be saved (portion_saved) 3. The cost of your dream home (total_cost) 4. The semi-​annual salary raise (semi_annual_raise) Hints 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. You should decide what information you need. Be sure to be careful about values that represent annual amounts and those that represent monthly amounts. ● Be careful about when you increase your salary – this should only happen ​after​ the 6​t​h​,​​ 12​t​h​​, 18​t​h ​month, and so on. Try different inputs and see how quickly or slowly you can save enough for a down payment. ​Please make your program print results in the format shown in the test cases below. Test Case 1 >>> Enter your starting annual salary:​ 120000 Enter the percent of your salary to save, as a decimal:​ .05 Enter the cost of your dream home: ​500000 Enter the semi​annual raise, as a decimal:​ .03 Number of months:​ 142

12th Jul 2019, 12:13 PM
Kianna Louise Guintu
Kianna Louise Guintu - avatar
2 Respostas
0
Please help me code this. I appreciate any kind of help
12th Jul 2019, 12:14 PM
Kianna Louise Guintu
Kianna Louise Guintu - avatar
0
salary=float(input("annual salary:")) print(salary) save_prctg =float(input("savings in decimal percentage")) print(save_prctg ) home=float(input("home downpayment amount")) print(home) hike=float(input("semi annual hike:")) print(hike) s=salary/12 #salary per month h=hike d=home sp=save_prctg sum=0 n=0 while d>sum: s=s*((h+1)**n) #salary after hike sa=sp*s #saving amount per month sum= sum+(sa*6) #print('d',sum,'s',s,'sa',sa) n+=1 #no. of six-months required #print('\n', n,sum) #if (sum-d)>sa r=(sum-d)//sa print("no. of months required ",(((n*6))-r)) Try this. It might work. Check the logic just in case
12th Jul 2019, 6:55 PM
sukumar yadavalli
sukumar yadavalli - avatar