Question:
a. productCost = 100
b. productPrice = productCost
c. productPrice = productName
d. productPrice = “24.95”
e. 15.67 = productCost
f. productCost = $1, 345.52
g. product Cost = productPrice − 10
h. productName = “mouse pad”
i. productCost + 20 = productPrice
j. productName = 3-inch nails
k. productName = 43
l. productName = “44”
m.“99” = productName
Answer:
(a) valid
(b) valid
(c) invalid
(d) valid
(e) invalid
(f) invalid
(g) invalid
(h) valid
(i) invalid
(j) invalid
(k) invalid
(l) valid
(m) invalid
Step-by-step explanation:
(a) valid. Since productCost is a numerical variable, a value of 100 can be assigned to it.
(b) valid. Both productCost and productPrice are numerical variables and as such value of one can be stored in the other.
(c) invalid. productName is a string variable and cannot be directly assigned to productPrice which is a numeric variable.
(d) valid. productPrice is a numeric variable and 24.95 can be assigned to it.
(e) invalid. 15.67 is not a variable name and as such cannot have values assigned to it.
(f) invalid. $ and , are not numeric digits and as such cannot be assigned to productCost which is numeric.
(g) invalid. There should be no space between product and Cost. It should be productCost and not product Cost.
(h) valid. "mouse pad" is a string literal and can be assigned to productName which is a string variable.
(i) invalid. productCost + 20 is not a variable .
(j) invalid. 3-inch nails should be in quotes for it to be assignable to productName.
(k) invalid. 43 is a numeric literal and cannot be directly assigned to productName which is a string variable. In other words, 43 should be in quotes for it to be assignable to productName.
(l) valid. 44 (in quotes) is a string literal and can be assigned to productName which is a string variable.
(m) invalid. "99" is not a variable name and cannot hold or be assigned any value.