Skip to content

Instantly share code, notes, and snippets.

@menon92
Last active February 1, 2019 15:28
Show Gist options
  • Save menon92/2de83df6b9594522d824590d4e277ab0 to your computer and use it in GitHub Desktop.
Save menon92/2de83df6b9594522d824590d4e277ab0 to your computer and use it in GitHub Desktop.
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 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 += 0.0125 * (account.principal * Math.exp( account.rate *
(account.daysActive / 365.25) ) - account.principal);
}
}
return totalFee;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment