Menu
Question Index
...


Write a program to calculate the balance at the end of day. Deduct Rs. 20 as overdraft charge (fine) every time the balance goes negative.

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

class CalculateEndOfDayBalanceApplyOverdraftCharges

{    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 end of the day is : " + calculateBalance(input, 25000.0));

    }


public static double calculateBalance(List<Transaction> transactions, double initialBalance) {
//Write code here to calculate the end of the day balance in the account after processing the transactions.
}
}
class Transaction {

int amount;
boolean isCredit;

public Transaction(int amount, boolean isCredit) {
this.amount = amount;
this.isCredit = isCredit;
}
}

Doubts

Problems

Topic: Java ArrayList

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App