/**
 * Calculates the total revenue generated by a marketing campaign
 */
fun calculateRevenue(): Double {

    val campaigns = mapOf(
        "Google" to mapOf(
            "clicks" to 500,
            "conversions" to 50,
            "conversion_rate" to 0.1,
            "cost_per_click" to 2.5
        ),
        "Facebook" to mapOf(
            "clicks" to 800,
            "conversions" to null,
            "conversion_rate" to null,
            "cost_per_click" to 1.8
        ),
        "Instagram" to mapOf(
            "clicks" to 1000,
            "conversions" to 100,
            "conversion_rate" to 0.1,
            "cost_per_click" to 1.7
        )
    )

    var totalRevenue = 0.0

    for ((platform, metrics) in campaigns) {
        val clicks = metrics["clicks"] as Int
        val conversions = metrics["conversions"] as Int?
        val conversionRate = metrics["conversion_rate"] as Double?
        val costPerClick = metrics["cost_per_click"] as Double

        if (conversions == null || conversionRate == null) {
            continue
        }

        val revenue = clicks * conversions * conversionRate - (clicks * costPerClick)
        totalRevenue += revenue
    }

    return totalRevenue
}
/**
 * Calculates the total revenue generated by a marketing campaign
 */
fun calculateRevenue(): Double {
/**
 * Calculates the total revenue generated by a marketing campaign
 */
fun calculateRevenue(): Double {

    val campaigns = mapOf(
        "Google" to mapOf(
            "clicks" to 500,
            "conversions" to 50,
            "conversion_rate" to 0.1,
            "cost_per_click" to 2.5
        ),
        "Facebook" to mapOf(
            "clicks" to 800,
            "conversions" to null,
            "conversion_rate" to null,
            "cost_per_click" to 1.8
        ),
        "Instagram" to mapOf(
            "clicks" to 1000,
            "conversions" to 100,
            "conversion_rate" to 0.1,
            "cost_per_click" to 1.7
        )
    )

    var totalRevenue = 0.0

    for ((platform, metrics) in campaigns) {
        val clicks = metrics["clicks"] as Int
        val conversions = metrics["conversions"] as Int?
        val conversionRate = metrics["conversion_rate"] as Double?
        val costPerClick = metrics["cost_per_click"] as Double

        if (conversions == null || conversionRate == null) {
            continue
        }

        val revenue = clicks * conversions * conversionRate - (clicks * costPerClick)
        totalRevenue += revenue
    }

    return totalRevenue
}