Solution:
final double VOLUME_CONVERSION = 0.814;
...
double volume = VOLUME_CONVERSION * height * height * height;
- Known as a named constant
- General form: final double name = value;
or final int name = value;
- Style issue: name in all upper case
- Should introduce a named constant for any non-trivial value in your
program
- Named constants make the code easier to read: "no magic/mystery numbers".
- Advantage of named constants: can change the value in just one place.
- For instance, the above factor to 6 digits is 0.813876.