Skip to content

Instantly share code, notes, and snippets.

Created July 5, 2017 17:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/f83b9bbf48b76bb40e23bf11a84afb3b to your computer and use it in GitHub Desktop.
Save anonymous/f83b9bbf48b76bb40e23bf11a84afb3b to your computer and use it in GitHub Desktop.
the description for this gist
case class Deposit(period: Int, interest: Double) {
def gain(amount: Double, duration: Int) = {
val interestPerPeriod = interest * (period / 12.0)
val fullPeriods = duration / period
val finalBalance = amount * math.pow(1 + interestPerPeriod, fullPeriods)
finalBalance - amount
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment