adding old solved challenges

This commit is contained in:
2024-10-15 11:03:57 -04:00
parent fa5ac5e089
commit 7ecd444efb
107 changed files with 1056 additions and 0 deletions
+35
View File
@@ -0,0 +1,35 @@
package Grades;
import java.util.ArrayList;
import java.util.List;
public class RoundGrades {
public static void main(String[] args) {
List<Integer> notes = new ArrayList<>();
notes.add(34);
notes.add(39);
notes.add(54);
notes.add(99);
notes.add(29);
notes.add(88);
System.out.println(studentsGrades(notes));
}
public static List<Integer> studentsGrades(List<Integer> grades) {
List<Integer> results = new ArrayList<>();
for (int grade : grades) {
if (grade < 38) {
results.add(grade);
} else {
int remainder = grade % 5;
int roundNum = grade + 5 - remainder;
results.add(roundNum - grade < 3 ? roundNum : grade);
}
}
return results;
}
}