program ToLetterGradeProgram;
function GetLetterGrade(score: Double): String;
var
scores: array[1..8] of Double = (95.0, 90.0, 85.0, 80.0, 75.0, 70.0, 65.0, 60.0);
grades: array[1..8] of String = ('A+', 'A', 'B+', 'B', 'C+', 'C', 'D+', 'D');
i: Integer;
begin
for i := 1 to Length(scores) do
begin
if score >= scores[i] then
begin
GetLetterGrade := grades[i];
Exit;
end;
end;
// If no match, return F
GetLetterGrade := 'F';
end;
var
score: Double;
begin
// Test the program with individual scores
Writeln(GetLetterGrade(95)); // A+
Writeln(GetLetterGrade(90)); // A
Writeln(GetLetterGrade(80)); // B
Writeln(GetLetterGrade(60)); // D
Writeln(GetLetterGrade(50)); // F
end.
(*
run:
A+
A
B
D
F
*)