Last active
February 1, 2019 15:46
-
-
Save menon92/c9ba6c5341be8d027fc75e6cb2f78920 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Account { | |
float principal; | |
float rate; | |
int daysActive; | |
int accountType; | |
public static final int STANDARD = 0; | |
public static final int BUDGET = 1; | |
public static final int PREMIUM = 2; | |
public static final int PREMIUM_PLUS = 3; | |
float interestEarned() { | |
return ( principal * (float) Math.exp( rate * (daysActive / 365.25 ) ) ) | |
- principal; | |
} | |
float calculateFee(Account accounts[]) { | |
float totalFee = 0; | |
Account account; | |
for (int i = 0; i < accounts.length; i++) { | |
account = accounts[i]; | |
if (account.accountType == Account.PREMIUM || | |
account.accountType == Account.PREMIUM_PLUS) { | |
totalFee += .0125 * account.interestEarned( ); | |
} | |
} | |
return totalFee; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment