Pagina de inicio
/
Tecnología
/
The following code segment is used to determine whether a customer is eligible for a discount on a movie ticket. val1arrow (NOT (category="new^n)) oR (age geqslant 65) val2arrow (category="new') AND (age lt 12) If category is "new" and age is 20, what are the values of val1 and val2 as a result of executing the code segment? A val1=true, val2=true B val1=true, val2=false C val1=false, val2=true D va11=false, val2=false

Problemas

The following code segment is used to determine whether a customer is eligible for a discount on a movie
ticket.
val1arrow (NOT (category="new^n)) oR (age geqslant 65)
val2arrow (category="new') AND (age lt 12)
If category is "new" and age is 20, what are the values of val1 and val2 as a result of
executing the code segment?
A val1=true, val2=true
B val1=true, val2=false
C val1=false, val2=true
D va11=false, val2=false

The following code segment is used to determine whether a customer is eligible for a discount on a movie ticket. val1arrow (NOT (category="new^n)) oR (age geqslant 65) val2arrow (category="new') AND (age lt 12) If category is "new" and age is 20, what are the values of val1 and val2 as a result of executing the code segment? A val1=true, val2=true B val1=true, val2=false C val1=false, val2=true D va11=false, val2=false

Solución

avatar
Alessandramaestro · Tutor durante 5 años
expert verifiedVerificación de expertos
4.4 (110 votos)

Responder

Let's break down the code segment step by step:<br /><br />1. **Initialization of $val1$**:<br /> - The expression for $val1$ is: <br /> \[<br /> val1 \leftarrow \text{NOT} (category = "new") \quad \text{OR} \quad (age \geq 65)<br /> \]<br /> - Given: <br /> \[<br /> category = "new" \quad \text{and} \quad age = 20<br /> \]<br /> - Evaluate the expression:<br /> \[<br /> \text{NOT} (category = "new") \quad \text{becomes} \quad \text{NOT} (true) \quad \text{which is} \quad false<br /> \]<br /> \[<br /> (age \geq 65) \quad \text{becomes} \quad (20 \geq 65) \quad \text{which is} \quad false<br /> \]<br /> - Combine the results using OR:<br /> \[<br /> val1 \leftarrow false \quad \text{OR} \quad false \quad \text{which is} \quad false<br /> \]<br /><br />2. **Initialization of $val2$**:<br /> - The expression for $val2$ is:<br /> \[<br /> val2 \leftarrow (category = "new") \quad \text{AND} \quad (age < 12)<br /> \]<br /> - Given:<br /> \[<br /> category = "new" \quad \text{and} \quad age = 20<br /> \]<br /> - Evaluate the expression:<br /> \[<br /> (category = "new") \quad \text{becomes} \quad true<br /> \]<br /> \[<br /> (age < 12) \quad \text{becomes} \quad (20 < 12) \quad \text{which is} \quad false<br /> \]<br /> - Combine the results using AND:<br /> \[<br /> val2 \leftarrow true \quad \text{AND} \quad false \quad \text{which is} \quad false<br /> \]<br /><br />Therefore, the values of $val1$ and $val2$ are:<br />\[<br />val1 = false \quad \text{and} \quad val2 = false<br />\]<br /><br />So, the correct answer is:<br />(D) $val1=false,\quad val2=false$
Haz clic para calificar: