Skip to content

Commit 46d9468

Browse files
solves grading students
1 parent 93b9daf commit 46d9468

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed
+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// https://www.hackerrank.com/challenges/grading/problem
2+
3+
package implimentation;
4+
5+
import java.util.Scanner;
6+
7+
public class GradingStudents {
8+
public static void main(String[] args) {
9+
Scanner scanner = new Scanner(System.in);
10+
int queries = scanner.nextInt();
11+
while (queries-- > 0) {
12+
int grade = scanner.nextInt();
13+
System.out.println(modifiedGrade(grade));
14+
}
15+
}
16+
17+
private static int modifiedGrade(int grade) {
18+
if (grade < 38) {
19+
return grade;
20+
}
21+
int next = (grade / 5) * 5 + 5 ;
22+
return next - grade < 3 ? next : grade;
23+
}
24+
}

0 commit comments

Comments
 (0)