File tree Expand file tree Collapse file tree
Algorithms/Implementation Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import java .io .*;
2+ import java .math .*;
3+ import java .text .*;
4+ import java .util .*;
5+ import java .util .regex .*;
6+
7+ public class Solution {
8+
9+ /*
10+ * Complete the gradingStudents function below.
11+ */
12+ static int [] gradingStudents (int [] grades ) {
13+ for (int i = 0 ; i < grades .length ; i ++) {
14+ for (int j = 40 ; j <= 100 ; j += 5 ) {
15+ if (j > grades [i ]) {
16+ if (j - grades [i ] <= 2 ) {
17+ grades [i ] = j ;
18+ }
19+ }
20+ }
21+ }
22+ return grades ;
23+ }
24+
25+ private static final Scanner scan = new Scanner (System .in );
26+
27+ public static void main (String [] args ) throws IOException {
28+ BufferedWriter bw = new BufferedWriter (new FileWriter (System .getenv ("OUTPUT_PATH" )));
29+
30+ int n = Integer .parseInt (scan .nextLine ().trim ());
31+
32+ int [] grades = new int [n ];
33+
34+ for (int gradesItr = 0 ; gradesItr < n ; gradesItr ++) {
35+ int gradesItem = Integer .parseInt (scan .nextLine ().trim ());
36+ grades [gradesItr ] = gradesItem ;
37+ }
38+
39+ int [] result = gradingStudents (grades );
40+
41+ for (int resultItr = 0 ; resultItr < result .length ; resultItr ++) {
42+ bw .write (String .valueOf (result [resultItr ]));
43+
44+ if (resultItr != result .length - 1 ) {
45+ bw .write ("\n " );
46+ }
47+ }
48+
49+ bw .newLine ();
50+
51+ bw .close ();
52+ }
53+ }
You can’t perform that action at this time.
0 commit comments