HackerLand University has the following grading policy:
Every student grade receives a 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 grade and the next multiple of 5 is less than 3, round up to the next multiple of 5.
If the value of grade is less 38 than , no rounding occurs as the result will still be a failing grade.
Answer
Every student grade receives a 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 grade and the next multiple of 5 is less than 3, round up to the next multiple of 5.
If the value of grade is less 38 than , no rounding occurs as the result will still be a failing grade.
Answer
static int[] gradingStudents(int[] grades) {
for(int i=0;i<grades.length;i++)
{
if(grades[i]>=38)
{
System.out.println(grades[i]%5);
if(grades[i]+(5-grades[i]%5)-grades[i]<3)
grades[i]=(grades[i]+(5-grades[i]%5));
}
}
return grades;
}
Tidak ada komentar:
Posting Komentar