/**
 * This function calculates the number of repetitions (reps) for a Physical Therapist based on given parameters.
 *
 * @param restTime The rest time in seconds between sets.
 * @param sets The total number of sets.
 * @return The total number of reps.
 */
fun calculateReps(restTime: Int, sets: Int): Int {

    var totalReps = 0
    var setNumber = 0

    while (setNumber < sets) {
        var currentSetReps = 0
        while (true) {
            // Prompting the therapist to enter the number of reps for the current set
            print("Enter the number of reps performed for set ${setNumber + 1}: ")
            val input = readLine()

            // Handling potential errors while converting input to integer
            try {
                val reps = input?.toInt() ?: 0
                if (reps < 0) {
                    throw NumberFormatException()
                }
                currentSetReps += reps

                // Checking if the reps entered exceed the suggested rest time
                if (currentSetReps > restTime) {
                    println("Reps entered exceed the rest time.")
                    break
                }
            } catch (e: NumberFormatException) {
                println("Invalid input! Reps must be a positive integer.")
            }
        }
        totalReps += currentSetReps
        setNumber++
    }

    return totalReps
}
/**
 * This function calculates the number of repetitions (reps) for a Physical Therapist based on given parameters.
 *
 * @param restTime The rest time in seconds between sets.
 * @param sets The total number of sets.
 * @return The total number of reps.
 */
fun calculateReps(restTime: Int, sets: Int): Int {
/**
 * This function calculates the number of repetitions (reps) for a Physical Therapist based on given parameters.
 *
 * @param restTime The rest time in seconds between sets.
 * @param sets The total number of sets.
 * @return The total number of reps.
 */
fun calculateReps(restTime: Int, sets: Int): Int {

    var totalReps = 0
    var setNumber = 0

    while (setNumber < sets) {
        var currentSetReps = 0
        while (true) {
            // Prompting the therapist to enter the number of reps for the current set
            print("Enter the number of reps performed for set ${setNumber + 1}: ")
            val input = readLine()

            // Handling potential errors while converting input to integer
            try {
                val reps = input?.toInt() ?: 0
                if (reps < 0) {
                    throw NumberFormatException()
                }
                currentSetReps += reps

                // Checking if the reps entered exceed the suggested rest time
                if (currentSetReps > restTime) {
                    println("Reps entered exceed the rest time.")
                    break
                }
            } catch (e: NumberFormatException) {
                println("Invalid input! Reps must be a positive integer.")
            }
        }
        totalReps += currentSetReps
        setNumber++
    }

    return totalReps
}