Four short programs about decisions, each with exactly one thing wrong. All four run perfectly and all four are wrong.
Not one of them produces an error message. Two of them even produce output that looks reasonable until you check it against what the program was supposed to say.
This should report a letter grade. A score of 95 prints D.
local score = 95
if score >= 60 then print("D")elseif score >= 70 then print("C")elseif score >= 80 then print("B")elseif score >= 90 then print("A")else print("F")endThis should describe the temperature in one word. At 85 it prints three lines.
local temp = 85
if temp > 80 then print("Hot")end
if temp > 60 then print("Warm")end
if temp > 40 then print("Cool")endThis should move only when the key is a or d. It prints moving for every key, including x.
local key = "x"
if key == "a" or "d" then print("moving")endThis one is worth more thought than the others. Nothing here is a typo.
An order of exactly $50 should get free shipping and nothing else. It prints the free shipping line and the missed-it line.
local total = 50
if total < 50 then print("Shipping: 6.00")else print("Free shipping")end
if total <= 50 then print("You just missed free shipping!")endFor each program, give:
Trace them on paper. Pick a value, follow it line by line, and write down what each condition evaluates to. That is the same skill the exam's trace questions want.
Worth 5 points, graded on completion.