A teacher uses the following program to adjust student grades on an assignment by adding 5 points to each student’s original grade. However, if adding 5 points to a student’s original grade causes the grade to exceed 100 points, the student will receive the maximum possible score of 100 points. The students’ original grades are stored in the list gradelist, which is indexed from 1 to n.

Respuesta :

The code segments that can  so that the program works as intended is option a)gradeList [i] ← min (gradeList[i] + 5, 100) and option  b)gradeList [i] ← gradeList[i] + 5

IF (gradeList [i] > 100)

{

gradeList [i] ← 100

}

Why are the statement correct?

Since min (gradeList[i] + 5, 100) returns the minimum of the two expressions, it returns gradeList[i] + 5 if this is less than 100 and 100 otherwise. The software will therefore increase each grade 5 point with this code if it does not result in a result greater than 100, and set it to 100 otherwise.

This code will first boost the value of each grade by 5 before verifying if the updated grade is more than 100 using an IF statement. If so, the IF block's code will execute, setting the grade's value to 100.

As a result, using this code, the program will increase each grade 5 point total if it does not result in a result greater than 100 and reset it to 100 in all other cases.

Learn more about code segments from

https://brainly.com/question/13506144
#SPJ1

See full question below

A teacher uses the following program to adjust student grades on an assignment by adding 5 points to each student's original grade. However, if adding 5 points to a student's original grade causes the grade to exceed 100 points, the student will receive the maximum possible score of 100 points. The students' original grades are stored in the list gradeList, which is indexed from 1 to n.

i ← 1

REPEAT n TIMES

{

i ← i + 1

}

The teacher has the following procedures available.

min (a, b): Returns the lesser of the two values a and b

max (a, b): Returns the greater of the two values a and b

Which of the following code segments can replace so that the program works as intended? Select two answers.

a)gradeList [i] ← min (gradeList[i] + 5, 100)

b)gradeList [i] ← gradeList[i] + 5

IF (gradeList [i] > 100)

{

gradeList [i] ← 100

}

c)gradeList [i] ← max (gradeList[i] + 5, 100)

d)gradeList [i] ← gradeList[i] + 5 IF (gradeList [i] > 100)

{

gradeList [i] ← gradeList[ [i] - 5

}

ACCESS MORE
EDU ACCESS
Universidad de Mexico