Functional Programming using Scala Tutorial 9
-
- Implement a Data Structure for Rational Number and create a method neg to class Rational that is used like this: x.neg // evaluates to -x
- Create a method sub to subtract two rational numbers and find an answer xy-z where x=3/4, y=5/8, z=2/7.
- Implement a Data Structure for Account and create a method transfer which transfers the money from this account to a given account. Basic functions: Deposit, Withdraw, Transfer
- A Bank is defined as a List of Accounts. So, implement the following functions: 4.1 List of Accounts with negative balances 4.2 Calculate the sum of all account balances 4.3 Calculate the final balances of all accounts after applying the interest function as follows: If balance is positive, deposit interest is .05 and if balance is negative, overdraft interest is .1