/**
 * A carpenter needs to know how much usable material is left after cutting.
 * Given the lengths of the workpiece and the amount of waste produced per cut,
 * write a function that calculates the total length of usable material left
 * after a series of cuts.
 *
 * @param workpiece The length of the original workpiece.
 * @param waste The length of waste produced per cut.
 * @return The total length of usable material left after the cuts.
 */
fun calculateLength(workpiece: Double, waste: Double): Double {

    var usableLength = workpiece

    while (usableLength > waste) {
        print("Enter the length of the next cut: ")
        val cutLength = readLine()!!.toDouble()

        usableLength -= (cutLength + waste)
    }

    return usableLength
}
/**
 * A carpenter needs to know how much usable material is left after cutting.
 * Given the lengths of the workpiece and the amount of waste produced per cut,
 * write a function that calculates the total length of usable material left
 * after a series of cuts.
 *
 * @param workpiece The length of the original workpiece.
 * @param waste The length of waste produced per cut.
 * @return The total length of usable material left after the cuts.
 */
fun calculateLength(workpiece: Double, waste: Double): Double {
/**
 * A carpenter needs to know how much usable material is left after cutting.
 * Given the lengths of the workpiece and the amount of waste produced per cut,
 * write a function that calculates the total length of usable material left
 * after a series of cuts.
 *
 * @param workpiece The length of the original workpiece.
 * @param waste The length of waste produced per cut.
 * @return The total length of usable material left after the cuts.
 */
fun calculateLength(workpiece: Double, waste: Double): Double {

    var usableLength = workpiece

    while (usableLength > waste) {
        print("Enter the length of the next cut: ")
        val cutLength = readLine()!!.toDouble()

        usableLength -= (cutLength + waste)
    }

    return usableLength
}