When mixing int and double in calculations, convert int to avoid losing precision. For `double average = (double) totalItems / count;`, the explicit cast prevents integer division.
Additional Notes
Why convert int to double in calculations?
Track: Java
Topic: Core Java
Focus: Numeric Types and Money Basics
Topics:Core JavaJavaNumeric Types and Money Basics