Grading Students Solution in Kotlin -HackerRank

  • Every student receives a grade in the inclusive range from 0 to 100 .
  • Any grade less than 40 is a failing grade.
  • If the difference between the grade and the next multiple of 5 is less than 3, round grade up to the next multiple of 5.
  • If the value of grade is less than 38, no rounding occurs as the result will still be a failing grade.
  • grade = 84 round to 85 (85–84 is less than 3)
  • grade = 29 do not round (result is less than 40)
  • grade = 57 do not round (60–57 is 3 or higher)
  • int grades[n]: the grades before rounding
  • int[n]: the grades after rounding as appropriate


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)
} else {
}return gradeList.toTypedArray()




Hey curious person, I am Software Developer

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

C++ enums illustrated

Tutorial Fuzzy Logic Mamdani for Arduino

Tutorial Fuzzy Logic Mamdani for Arduino

IPFS Explained In 2min

Packaging Github Projects using Homebrew

How Ready is Your Small Business For the Cloud?

Gitlab CI/CD + Helm to deploy PHP Application on Kubernetes

Opening the box: Django Design Philosophy.

An Introduction to GitHub

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
Umar Syaid Himawan

Umar Syaid Himawan

Hey curious person, I am Software Developer

More from Medium

Ideas and Solutions for Advent of Code 2021 in Kotlin — Part 3/4

JDK 17 — Unsupported Class File Major Version

Use AWS CodeArtifact in your project.

Observer pattern for loose coupling

Drawing of the observer pattern