Hello **Programmers/Coders,** Today we are going to share ** solutions of Programming problems of HackerRank, Algorithm Solutions of Problem Solving Section in Java**. At Each Problem with Successful submission with

**all Test Cases Passed,**you will get an score or marks. And after solving maximum problems, you will be getting stars. This will highlight your profile to the recruiters.

In this post, you will find the solution for **Grading Students** **in Java-HackerRank Problem**. We are providing the **correct and tested solutions** of coding problems present on **HackerRank**. If you are not able to solve any problem, then you can take help from our Blog/website.

Use “Ctrl+F” To Find Any Questions Answer. & For Mobile User, You Just Need To Click On Three dots In Your Browser & You Will Get A “Find” Option There. Use These Option to Get Any Random Questions Answer.

**Introduction To Algorithm**

The word **Algorithm** means “a process or set of rules to be followed in calculations or other problem-solving operations”. Therefore Algorithm refers to a set of rules/instructions that step-by-step define how a work is to be executed upon in order to get the expected results.

**Advantages of Algorithms:**

- It is easy to understand.
- Algorithm is a step-wise representation of a solution to a given problem.
- In Algorithm the problem is broken down into smaller pieces or steps hence, it is easier for the programmer to convert it into an actual program.

** Link for the Problem** – Grading Students – Hacker Rank Solution

**Grading Students– Hacker Rank Solution**

**Problem:**

HackerLand University has the following grading policy:

- Every student receives a in the inclusive range from to .
- Any less than is a failing grade.

Sam is a professor at the university and likes to round each student’s according to these rules:

- If the difference between the and the next multiple of is less than , round up to the next multiple of .
- If the value of is less than , no rounding occurs as the result will still be a failing grade.

**Examples**

- round to (85 – 84 is less than 3)
- do not round (result is less than 40)
- do not round (60 – 57 is 3 or higher)

Given the initial value of for each of Sam’s students, write code to automate the rounding process.

**Function Description**

Complete the function *gradingStudents* in the editor below.

gradingStudents has the following parameter(s):

*int grades[n]*: the grades before rounding

**Returns**

*int[n]*: the grades after rounding as appropriate

**Input Format**

The first line contains a single integer, , the number of students.

Each line of the subsequent lines contains a single integer, .

**Constraints**

**Sample Input 0**

4 73 67 38 33

**Sample Output 0**

75 67 40 33

**Explanation 0**

- Student received a , and the next multiple of from is . Since , the student’s grade is rounded to .
- Student received a , and the next multiple of from is . Since , the grade will not be modified and the student’s final grade is .
- Student received a , and the next multiple of from is . Since , the student’s grade will be rounded to .
- Student received a grade below , so the grade will not be modified and the student’s final grade is .

Grading Students – Hacker Rank Solution

import java.util.Scanner; /** * @author Techno-RJ * */ public class GradingStudents { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); for (int a0 = 0; a0 < n; a0++) { int grade = in.nextInt(); System.out.println(grade < 38 || grade % 5 < 3 ? grade : grade + (5 - grade % 5)); in.close(); } } }