0

Who can figure this out ??

IN PYTHON: Build an algorithm that calculates your savings at retirement.. -invest an unknown amount at the end of every year -earn an unknown intrest rate on their savings -DOUBLE their annual investment every second year

27th Sep 2018, 2:42 PM
Mario Moshogiannis
Mario Moshogiannis - avatar
9 ответов
+ 2
Sorry but i think that it must work differently... Follow my try: - year 1 investiment: 100 earn: 50% = 50 total savings: 150 - year 2 investiment: 200 earn: 50% = 100 total savings= 150 + 300= 450 - year 3 investiment: 200 earn: 50% = 100 total savings: 450 + 300= 750 - year 4 investiment: 400 earn: 50% = 200 total savings: 750 + 600= 1350
27th Sep 2018, 9:49 PM
KrOW
KrOW - avatar
+ 2
Why you dont post your try? In this way we can help but dont think that someome make YOUR assignement for you P.S. Please, dont spam other discussion
27th Sep 2018, 3:06 PM
KrOW
KrOW - avatar
+ 1
def oh(PV,i,n):         FV=PV     for j in range(n):         if j % 2 == 0:             interest = (FV*2) *i                          FV = FV + interest             print(FV)         else:             interest = FV * i             FV = FV + interest       return FV
27th Sep 2018, 7:49 PM
Mario Moshogiannis
Mario Moshogiannis - avatar
+ 1
Mario Moshogiannis Ok... I dont understand one thing... Why you calculate interest every year? You cannot do it to end?
27th Sep 2018, 8:59 PM
KrOW
KrOW - avatar
+ 1
Mario Moshogiannis Just for understand what you have to find, you can tell me what your algorithm would return for: - after 1 year, with 10 as initial amount and 0% interest - after 1 year, with 10 as initial amount and 5% interest - after 2 year, with 10 as initial amount and 0% interest - after 2 year, with 10 as initial amount and 5% interest
27th Sep 2018, 9:09 PM
KrOW
KrOW - avatar
+ 1
let me try this year 1 =100 +50% so end of year 1 =150 year 2 the man deposits 200 .. so 350.. +50% = 525.. year 3 man deposited 200 again.. so 725 +50% = 1087.50 year 4... man deposits 400... so 1487.50 +50% = 2231.25 this is what i could understand from the question im just struggling to get it to work as an algorithm
27th Sep 2018, 9:16 PM
Mario Moshogiannis
Mario Moshogiannis - avatar
+ 1
yours is making more sence.. but do i keep the same structure with running a loop ans an if statement in my loop?
28th Sep 2018, 7:02 AM
Mario Moshogiannis
Mario Moshogiannis - avatar
0
its a savings account so interest builds yearly
27th Sep 2018, 9:03 PM
Mario Moshogiannis
Mario Moshogiannis - avatar
0
you can keep same structure but remember than range(n) retunr (0,1,2...n) then the first year is 0 and because 0%2 equals to 0 you get doubled your investiments every 2 years but starting from first year (and its not that do you want i think)... Futhermore if you apply interest to only saving year, you can calculate final saving applying interest at last (without calculate it every year). Following my previous example: totalSavingsWithoutInt= 100+200+200+400= 900 totalSavings= 900 * (interest + 1)= 900 * 1.5= 1350
28th Sep 2018, 8:38 AM
KrOW
KrOW - avatar