We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Grading Students
Grading Students
Sort by
recency
|
3844 Discussions
|
Please Login in order to post a comment
PYTHON
Javascript :-
let n1 = []; let update = items.map((item) => { if (item < 38) { n1.push(item); } else { let nextMultipleBy5 = Math.round(item / 5); if (nextMultipleBy5 * 5 > item) { n1.push(Math.abs(nextMultipleBy5 * 5 - item) < 3 ? nextMultipleBy5 * 5 : item); } else { n1.push(Math.abs((nextMultipleBy5 + 1) * 5 - item) < 3 ? (nextMultipleBy5 + 1) * 5 : item); } } }); console.log(n1); return n1;
Python
Python
public static List gradingStudents(List grades) { // Write your code here List newList = new ArrayList<>(); for(Integer x : grades){ if(x >= 38){ // case (x)0 -> (x)4 if(x%10 < 5 ){ if( 5 - (x%10) < 3) x = x + (5 - (x%10)); } //case (x)5 -> (x)9 else{ if( 5 - (x%10) <= -3 && 5 - (x%10) != 0 ) x = x + (5 - (x%10) + 5); } } newList.add(x); } return newList;