/**
 * The function calculates the density of sedimentary rocks based on their rock type and porosity.
 *
 * @param rockType The type of rock. Can be 'sandstone', 'shale', or 'limestone'.
 * @param porosity The porosity of the rock, represented as a decimal number between 0 and 1.
 * @return The calculated density of the sedimentary rock.
 */
fun calculateDensity(rockType: String, porosity: Double): Double? {

    var density: Double? = null
    
    // Check the rock type using nested ternary operators
    density = if (rockType == "sandstone") 2.6
    else if (rockType == "shale") 2.7
    else if (rockType == "limestone") 2.8
    else null
    
    // Check the porosity using nested ternary operators
    density = if (density != null) density * (1 - porosity) else null
    
    return density
}
/**
 * The function calculates the density of sedimentary rocks based on their rock type and porosity.
 *
 * @param rockType The type of rock. Can be 'sandstone', 'shale', or 'limestone'.
 * @param porosity The porosity of the rock, represented as a decimal number between 0 and 1.
 * @return The calculated density of the sedimentary rock.
 */
fun calculateDensity(rockType: String, porosity: Double): Double? {
/**
 * The function calculates the density of sedimentary rocks based on their rock type and porosity.
 *
 * @param rockType The type of rock. Can be 'sandstone', 'shale', or 'limestone'.
 * @param porosity The porosity of the rock, represented as a decimal number between 0 and 1.
 * @return The calculated density of the sedimentary rock.
 */
fun calculateDensity(rockType: String, porosity: Double): Double? {

    var density: Double? = null
    
    // Check the rock type using nested ternary operators
    density = if (rockType == "sandstone") 2.6
    else if (rockType == "shale") 2.7
    else if (rockType == "limestone") 2.8
    else null
    
    // Check the porosity using nested ternary operators
    density = if (density != null) density * (1 - porosity) else null
    
    return density
}