What is the value of the variable shipping if cost = 50 and
country = "Canada"?
if (cost < 50 && country == "Canada")
shipping = 6.00;
if (cost < 100 && cost > 49 && country == "Canada")
shipping = 9.00;
else
shipping = 12.00;
A. 12.00
B. cannot tell since the else clause does not specify the conditions
C. 9.00
D. 6.00
C. 9.00 Explanation: ------------- if (cost < 50 && country == "Canada") 50 < 50 && "Canada" == "Canada" = false && true = false shipping = 6.00; // so, this is not executed if (cost < 100 && cost > 49 && country == "Canada") // 50<100 && 50>49 && "Canada"=="Canada" = true && true && true = true shipping = 9.00; // so, shipping is set to 9.00 else shipping = 12.00; Answer: 9.00
Get Answers For Free
Most questions answered within 1 hours.