/**
 * This function takes in an income statement and an account type and returns the total balance for that account type.
 *
 * @param incomeStatement A list of pairs containing the account name and its corresponding balance.
 * @param accountType The type of account to calculate the total balance for.
 * @return The total balance for the specified account type.
 */
fun accountCalculation(incomeStatement: List<Pair<String, Int>>, accountType: String): Float {

    var totalBalance = 0f

    for ((account, balance) in incomeStatement) {
        when (accountType) {
            "asset" -> {
                // only consider positive balances for assets
                if (balance > 0) {
                    totalBalance += balance
                }
            }
            "liability" -> {
                // only consider negative balances for liabilities
                if (balance < 0) {
                    totalBalance += balance
                }
            }
            "expense", "revenue" -> {
                // only consider negative balances for expenses and positive balances for revenues
                if ((accountType == "expense" && balance < 0) || (accountType == "revenue" && balance > 0)) {
                    totalBalance += balance
                }
            }
        }
    }

    return totalBalance
}

// Example usage
val incomeStatement = listOf(
    Pair("Cash", 5000)
)
/**
 * This function takes in an income statement and an account type and returns the total balance for that account type.
 *
 * @param incomeStatement A list of pairs containing the account name and its corresponding balance.
 * @param accountType The type of account to calculate the total balance for.
 * @return The total balance for the specified account type.
 */
fun accountCalculation(incomeStatement: List<Pair<String, Int>>, accountType: String): Float {
/**
 * This function takes in an income statement and an account type and returns the total balance for that account type.
 *
 * @param incomeStatement A list of pairs containing the account name and its corresponding balance.
 * @param accountType The type of account to calculate the total balance for.
 * @return The total balance for the specified account type.
 */
fun accountCalculation(incomeStatement: List<Pair<String, Int>>, accountType: String): Float {

    var totalBalance = 0f

    for ((account, balance) in incomeStatement) {
        when (accountType) {
            "asset" -> {
                // only consider positive balances for assets
                if (balance > 0) {
                    totalBalance += balance
                }
            }
            "liability" -> {
                // only consider negative balances for liabilities
                if (balance < 0) {
                    totalBalance += balance
                }
            }
            "expense", "revenue" -> {
                // only consider negative balances for expenses and positive balances for revenues
                if ((accountType == "expense" && balance < 0) || (accountType == "revenue" && balance > 0)) {
                    totalBalance += balance
                }
            }
        }
    }

    return totalBalance
}

// Example usage
val incomeStatement = listOf(
    Pair("Cash", 5000)
)