Grading Students Solution in Kotlin -HackerRank

4 
73
67
38
33
75 
67
40
33

ANSWER

fun gradingStudents(grades: Array<Int>): Array<Int> {var gradeList : MutableList<Int> = ArrayList()   grades.forEach() { item ->        if  (item >= 38 && item % 5 > 2 ) {
val total = item + (5 - item % 5)
gradeList.add(total)
} else {
gradeList.add(item)
}
}return gradeList.toTypedArray()
}

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store