Lab07 - CS61A of UCB(2021-Fall)
Accounts
Q2: Retirement
Add a
time_to_retire
method to theAccount
class. This method takes in anamount
and returns how many years the holder would need to wait in order for the currentbalance
to grow to at leastamount
, assuming that the bank addsbalance
times theinterest
rate to the total balance at the end of every year.
The description tells us that: We will add our balance
every year, so when may we retire? Both the math and code are simple.