info@meritcampus.com    +91-85006-22255
...

Write a program to calculate the balance at the end of day. Apply 1.5% of the negative balance as overdraft charge (fine), every time the balance goes into negative.
If the balance is -500 then the fine will be Rs 7.5.

Input (List, double) Output (double)
{[500, true], [1000, false], [600, true], [500, true], [2000, false]}, 1000.0 -406.0
{[20000, false], [8000, false], [14000, true], [15000, true]}, 25000.0 25955.0
{[100, true], [200, true], [600, false], [200, true], [50, false]}, 300.0 150.0
{[4000, true], [5000, true], [20000, false]}, 6000.0 -5075.0

``` class CalculateEndOfDayBalanceApplyVariableOverdraftCharges {    public static void main(String s[])    {        ArrayList input = new ArrayList();        input.add(new Transaction(20000, false));        input.add(new Transaction(5000, false));        input.add(new Transaction(8000, false));        input.add(new Transaction(1000, true));        input.add(new Transaction(200, false));        input.add(new Transaction(1000, false));        input.add(new Transaction(5000, true));        System.out.println("The balance at the end of the day is : " + getBalance(input, 25000.0));    } public static double getBalance(List<Transaction> transactions, double initialBalance) { //Write code here to calculate the balance in the account after all transactions } } class Transaction { int amount; boolean isCredit; public Transaction(int amount, boolean isCredit) { this.amount = amount; this.isCredit = isCredit; } } ```

Topic: Java ArrayList

0
Wrong
Score more than 2 points