List of students' grades

Report a typo

Taking a collection of qualifications as a List, obtain the average grade of the students who have passed the exam.

You must create an infix function called average on a list of Doubles. It accepts a parameter – the markLimit score – as a double and returns a double value – the average value of the list elements greater than or equal to this limit.

val listOfGrades = listOf(5.5, 4.6, 3.0, 2.5, 10.0, 9.9, 8.75)
println(listOfGrades average 5.0)

Sample Input 1:

5.5 4.6 3.0 2.5 10.0 9.9 8.75

Sample Output 1:

8.5375
Write a program in Kotlin
// complete the definition
/*?*/.average(markLimit: Double): Double {
// write the rest of the code
}
___

Create a free account to access the full topic