- First and most important remark : do not use
double
orfloat
to represent money. UseBigDecimal
instead. And make aMoney
class that combines the amount with the currency. edit : it's also possible to use long or int, if you always calculate in cents, this would make aMoney
class even more useful, to hide away that implementation detail. - Think about rounding and precision. How many fractional digits can an annual rate have, how many can a monthly rate have...? How will you round if needed?
- Don't hard code the values of the rates. If there's anything banks like to change it is their rates. :)
- I would find it very odd if the date of the withdrawals and deposits did not matter in calculating the interests.
- I'm not sure how
NewWithdrawl
andNewDeposit
are supposed to get their values, from the posted code. As is these fields don't seem to make much sense, it feels like they want to be parameters of methods yet to be defined. getWithdrawl()
(sic)(sic) seems to do the same sort of operation as depositdeposit()
, yet the former is named as a getter method (while it isn't one) and the latter is not. Preferably they'd be named consistently.