mester.pdf
Open with Google Docs
9. The following code segment is used to determine whether a customer is eligible for a discount on a movie ticket
\[
\begin{array}{l}
\text { vall } \leftarrow(\text { NOT }(\text { category }=\text { "new") }) \text { OR (age } \geq 65) \\
\text { vald } \leftarrow \text { (category }=\text { "new") AND (age < 12) }
\end{array}
\]
If category is "new" and age is 20 , what are the values of vall and vall as a result of executio the code segment?
(A) vall = true, vall \( = \) true
(B) vall = true, vall = false
(C) vall \( = \) false, vall \( = \) true
(D) vall = false, vall \( = \) false
10. In the following code segment, score and penalty are initially positive integers. The code segment is intended to reduce the value of score by penalty. However, if doing so would cause score to be negative, score should be assigned the value 0 .
For example, if score is 20 and penalty is 5 , the code segment should set score to 15 . If score is 20 and penalty is 30 , score should be set to 0 .
The code segment does not work as intended.
```
Line 1: IF(score - penalty < 0)
Line 2: 1
Line 3: score \leftarrow score - penalty
Line 4: 1
Line 5: ElSE
Line 6: {
Line 7: score }\leftarrow
Line 8: }
```
Which of the following changes can be made so that the code segment works as intended?
(A) Changing line 1 to IF (score < 0)
(B) Changing line 1 to IF (score + penalty < 0)
(C) Changing line 7 to score \( \leftarrow \) score + penalty
(D) Interchanging lines 3 and 7
11. To qualify for a particular scholarship, a student must have an overall grade point average of 3.0 or above and must have a science grade point average of over 3.2. Let overallGPA represent a student's overall grade point average and let scienceGPA represent the student's science grade point average. Which of the following expressions evaluates to true if the student is eligible for the scholarship and evaluates to false otherwise?
(A) (overallGPA \( >3.0 \) ) AND (scienceGPA \( >3.2 \) )
(B) (overallGPA \( >3.0 \) ) AND (sciencegPA \( \geq 3.2 \) )
(C) loverallGPA \( \geq 3.0 \) ) AND (scienceGPA \( >3.2 \) )
(D) loverallGPA \( \geq 3.9 \)
Page
7
25