Answer:
SET totalGrades to 0
SET totalPoints to 0
SET numGrades to INPUT from user
SET grades[numGrades] to empty array
IF numGrades <= 0 THEN
OUTPUT "The number of grades to enter must be greater than 0."
ELSE
FOR i from 0 to numGrades-1 DO
SET grade to INPUT from user
IF grade < 0 OR grade > 4 THEN
SET grade to 0
END IF
SET grades[i] to grade
SET totalPoints to totalPoints + grade
END FOR
Step-by-step explanation:
FOR i from 0 to numGrades-1 DO
SET letterGrade to empty string
IF grades[i] == 4 THEN
SET letterGrade to "A"
ELSE IF grades[i] == 3 THEN
SET letterGrade to "B"
ELSE IF grades[i] == 2 THEN
SET letterGrade to "C"
ELSE IF grades[i] == 1 THEN
SET letterGrade to "D"
ELSE
SET letterGrade to "F"
END IF
OUTPUT "The following grades: " + letterGrade + " "
END FOR
SET gpa to totalPoints / numGrades
OUTPUT "Earned a GPA of: " + gpa
END IF