TopCoder problem "Finances" used in SRM 1 (Division I Level One , Division II Level One)

Problem Statement

Implement a class Finances, which contains a function timeLeft.  timeLeft is
passed three int values.  The initial value of the bank account is
initialValue.  Interest is compounded monthly at a rate of interest percent.
Every month monthly dollars is taken out from the account (immediately after
the Interest has been added).  timeLeft must return an int that is the number
of months the account can support the full monthly withdrawal.  If the account
will last longer than 1200 months, the function should return 1200.

The method signature is:
int timeLeft(int initialValue, int interest, int monthly).

NOTE: initialValue and monthly are greater than or equal to 0 and less than or
equal to 100,000.  interest is greater than or equal to 0 and less than or
equal to 1000.

(100, 0, 100) -> 1
(200, 1, 300) -> 0
(3453, 8, 200) -> 1200


Parameters:int, int, int
Method signature:int timeLeft(int param0, int param1, int param2)
(be sure your method is public)

Problem url:

Problem stats url:




Problem categories: