User Story
As a school administrator, I want to implement a grading system that assigns grades (A, B, C, D, F) to students based on their scores, so that I can efficiently evaluate and communicate student performance to parents and faculty.
Codes
public class SchoolGrading{
public static String getTaskPriority(Integer score) {
String grade;
if (score > 85) {
grade = 'A';
} else if (score > 70) {
grade = 'B';
} else if (score > 60) {
grade = 'C';
} else if (score > 50) {
grade = 'D';
} else {
grade = 'F';
}
return grade;
}
}
Apex Test Class
@isTest
private class SchoolGradingTest {
@isTest
static void testGetTaskPriority() {
Integer score = 90;
String expectedGrade = 'A';
String actualGrade = SchoolGrading.getTaskPriority(score);
System.assertEquals(expectedGrade, actualGrade, 'Expected grade to be "A" for score of 90');
score = 75;
expectedGrade = 'B';
actualGrade = SchoolGrading.getTaskPriority(score);
System.assertEquals(expectedGrade, actualGrade, 'Expected grade to be "B" for score of 75');
score = 65;
expectedGrade = 'C';
actualGrade = SchoolGrading.getTaskPriority(score);
System.assertEquals(expectedGrade, actualGrade, 'Expected grade to be "C" for score of 65');
score = 55;
expectedGrade = 'D';
actualGrade = SchoolGrading.getTaskPriority(score);
System.assertEquals(expectedGrade, actualGrade, 'Expected grade to be "D" for score of 55');
score = 40;
expectedGrade = 'F';
actualGrade = SchoolGrading.getTaskPriority(score);
System.assertEquals(expectedGrade, actualGrade, 'Expected grade to be "F" for score of 40');
}
}
Video
Video does not exists.