Transaction system

Report a typo

Imagine that you need to build a transaction system. Each transaction increases, decreases, or leaves unchanged the total balance on the account. The initial balance is zero. If the result of a transaction is lower than zero, then the total balance on this account will be blocked and the returned value will be equal to the balance before the transaction.

Write a method that returns the total balance.

Sample Input 1:

1000 2000 3000

Sample Output 1:

6000

Sample Input 2:

1000 2000 -3100

Sample Output 2:

3000
Write a program in Kotlin
import java.util.concurrent.Callable
import java.util.concurrent.Executors

fun transactionSystem(transactions: List<Callable<Int>>): Int {
val executor = Executors.newFixedThreadPool(4)

// write your code here

executor.shutdown()
}
___

Create a free account to access the full topic