Exam-style question
Try this first
A program uses the same tax rate in several calculations. Which approach best applies the idea of a named constant?.
- A.Store the rate under a meaningful constant name and use that name in the calculations
- B.Use a different literal rate in each calculation
- C.Store the rate in a variable and deliberately change it before every calculation
- D.Replace the rate with a comment
Answer and explanation
Concise answer
Store the rate under a meaningful constant name and use that name in the calculations
Why this is correct
A named constant gives the shared value a meaningful identity and helps keep the value consistent wherever it is used.
Use the concise answer above for a quick check, then reveal the full model answer and detailed explanation.
Common mistake
No common mistake is linked to this question yet.
