HR - Graduating Students
문제
HackerLand University has the following grading policy:
Every student receives agrade in the inclusive range from 0 to 100.
Any grade  less than 40 is a failing grade.
Sam is a professor at the university and likes to round each student's grade according to these rules:
- If the difference between the gradeand the next multiple of5is less than3, roundgradeup to the next multiple of5.
- If the value of gradeis less than38, no rounding occurs as the result will still be a failing grade.
Examples
- grade= 84 round to- 85(85 - 84 is less than 3)
- grade= 29 do not round (result is less than 40)
- grade= 57 do not round (60 - 57 is 3 or higher)
예시
//Input
4
73
67
38
33//Output
75
67
40
33풀이
- 학생의 학점과 가장 (큰쪽으로) 가까운 5의 배수와의 차가 3 미만이면 올림을 하는 문제이다.
- 학점 배열과 5의 배수 배열을 이중 루프로 돌면서 비교하면 될 것 같다.
코드
function gradingStudents(grades) {
    const multipleOf5 = [40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100];
   
    for(let i = 0; i < grades.length; i++) {
        for(let j = 0; j < multipleOf5.length; j++) {
            if(multipleOf5[j] - grades[i] < 3 && multipleOf5[j] - grades[i] > 0) {
                grades[i] = multipleOf5[j];
            }
        } 
    }
    return grades;
}Author And Source
이 문제에 관하여(HR - Graduating Students), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://velog.io/@goody/HR-Graduating-Students저자 귀속: 원작자 정보가 원작자 URL에 포함되어 있으며 저작권은 원작자 소유입니다.
                                
                                
                                
                                
                                
                                우수한 개발자 콘텐츠 발견에 전념
                                (Collection and Share based on the CC Protocol.)