forked from RyanFehr/HackerRank
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSolution.java
42 lines (34 loc) · 1 KB
/
Solution.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
//Problem: https://www.hackerrank.com/challenges/grading
//Java 8
/*
Initial Thoughts:
We can use division and multiplication
to find the next factor of 5 then
just check our conditions and
return the proper grade
Time Complexity: O(n) //In the number of grades
Space Complexity: O(1) //We only ever store two integers in memory
*/
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Solution {
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();
int newGrade = ((grade / 5) + 1) * 5;
if(newGrade < 40)
{
System.out.println(grade);
continue;
}
if(newGrade - grade < 3) System.out.println(newGrade);
else
System.out.println(grade);
}
}
}