forked from DedSecInside/Awesome-Scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGrading Students.java
64 lines (44 loc) · 1.46 KB
/
Grading Students.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import java.io.*;
import java.math.*;
import java.text.*;
import java.util.*;
import java.util.regex.*;
public class Solution {
/*
* Complete the gradingStudents function below.
*/
static int[] gradingStudents(int[] grades) {
/*
* Write your code here.
*/
int[] result = new int[grades.length];
for(int i=0;i<grades.length;i++){
if(grades[i]<38)
result[i]=grades[i];
else if(grades[i]%5!=0 && grades[i]%5>=3)
result[i] = (grades[i] - grades[i]%5)+5;
else
result[i]=grades[i];
}
return result;
}
private static final Scanner scan = new Scanner(System.in);
public static void main(String[] args) throws IOException {
BufferedWriter bw = new BufferedWriter(new FileWriter(System.getenv("OUTPUT_PATH")));
int n = Integer.parseInt(scan.nextLine().trim());
int[] grades = new int[n];
for (int gradesItr = 0; gradesItr < n; gradesItr++) {
int gradesItem = Integer.parseInt(scan.nextLine().trim());
grades[gradesItr] = gradesItem;
}
int[] result = gradingStudents(grades);
for (int resultItr = 0; resultItr < result.length; resultItr++) {
bw.write(String.valueOf(result[resultItr]));
if (resultItr != result.length - 1) {
bw.write("\n");
}
}
bw.newLine();
bw.close();
}
}