Sovi.AI - AI Math Tutor

Scan to solve math questions

QUESTION IMAGE

examine the following pseudocode, which is intended to charge $10 shipp…

Question

examine the following pseudocode, which is intended to charge $10 shipping for orders more than $5 but less than $50, and $5 shipping for other orders. what type of error is present?
if ordertotal > 5 or ordertotal < 50 then

shippingcost = 10

else

shippingcost = 5

endif
○ a dead path
○ b trivial expression
○ c incomplete expression
○ d unstructured selection

Explanation:

Brief Explanations

The condition orderTotal > 5 OR orderTotal < 50 is a trivial expression because for any number, either it is greater than 5 or less than 50 (or both), so the condition is always true. This means the else block (shippingCost = 5) is a dead path, but the error in the condition itself is a trivial expression as it doesn't properly restrict to the intended range (5 < orderTotal < 50, which should use AND instead of OR). Wait, no—actually, the condition A OR B where A is >5 and B is <50 will always be true because any number is either >5 or <50 (e.g., 3 is <50, 100 is >5, 30 is both). So the condition is always true, making the else block unreachable (dead path), but the error in the condition's logic is a trivial expression (since it's always true, the condition is trivial). Wait, the options: "trivial expression" means an expression that is always true or always false. Here, orderTotal >5 OR orderTotal <50 is always true (because for any number, it's either >5 or <50). So the condition is a trivial (always true) expression, so the error is a trivial expression.

Answer:

b. trivial expression