/**
 * Given a string containing numeric values and a desired number of decimal places, round the numeric values in the
 * string to the specified number of decimal places.
 *
 * @param string A string containing numeric values.
 * @param numDecimalPlaces The desired number of decimal places for rounding.
 * @return The string with numeric values rounded to the specified number of decimal places.
 *
 * Example:
 * roundStringPrecision("The temperature is 28.54956 degrees Celsius.", 2)
 * Output: "The temperature is 28.55 degrees Celsius."
 */
fun roundStringPrecision(string: String, numDecimalPlaces: Int): String {

    var roundedString = ""
    var numericValue = ""

    for (char in string) {
        if (char.isDigit() || char == '.') {
            numericValue += char
        } else {
            if (numericValue.isNotEmpty()) {
                val roundedNumber = "%.${numDecimalPlaces}f".format(numericValue.toDouble())
                roundedString += roundedNumber
                numericValue = ""
            }
            roundedString += char
        }
    }

    return roundedString
}

// Exercise to practice manipulating a string using loops and rounding precision of floating-point numbers

// Physician's statement
val statement = ""
/**
 * Given a string containing numeric values and a desired number of decimal places, round the numeric values in the
 * string to the specified number of decimal places.
 *
 * @param string A string containing numeric values.
 * @param numDecimalPlaces The desired number of decimal places for rounding.
 * @return The string with numeric values rounded to the specified number of decimal places.
 *
 * Example:
 * roundStringPrecision("The temperature is 28.54956 degrees Celsius.", 2)
 * Output: "The temperature is 28.55 degrees Celsius."
 */
fun roundStringPrecision(string: String, numDecimalPlaces: Int): String {
/**
 * Given a string containing numeric values and a desired number of decimal places, round the numeric values in the
 * string to the specified number of decimal places.
 *
 * @param string A string containing numeric values.
 * @param numDecimalPlaces The desired number of decimal places for rounding.
 * @return The string with numeric values rounded to the specified number of decimal places.
 *
 * Example:
 * roundStringPrecision("The temperature is 28.54956 degrees Celsius.", 2)
 * Output: "The temperature is 28.55 degrees Celsius."
 */
fun roundStringPrecision(string: String, numDecimalPlaces: Int): String {

    var roundedString = ""
    var numericValue = ""

    for (char in string) {
        if (char.isDigit() || char == '.') {
            numericValue += char
        } else {
            if (numericValue.isNotEmpty()) {
                val roundedNumber = "%.${numDecimalPlaces}f".format(numericValue.toDouble())
                roundedString += roundedNumber
                numericValue = ""
            }
            roundedString += char
        }
    }

    return roundedString
}

// Exercise to practice manipulating a string using loops and rounding precision of floating-point numbers

// Physician's statement
val statement = ""