User Story
Write a code that returns the corresponding letter grade based on the following grading scale:
- Score 90 or above: 'A'
- Score 80-89: 'B'
- Score 70-79: 'C'
- Score 60-69: 'D'
- Score below 60: 'F'
Use a switch statement to implement the grading logic.
Code
Integer score = 75;
switch on (score / 10) {
when 9, 10 {
letterGrade = 'A';
}
when 8 {
letterGrade = 'B';
}
when 7 {
letterGrade = 'C';
}
when 6 {
letterGrade = 'D';
}
when else {
letterGrade = 'F';
}