Skip to main content

Practice ยท 4 of 4

Debug: the method that prints instead of returning

bmiReport below compiles and prints, but it is untestable: the verdict is printed, not returned, and the category logic lives inline. Refactor: static String category(double bmi) returns "under", "normal", or "over" (< 18.5 under; 18.5โ€“24.9 normal; 25+ over), and bmiReport RETURNS "BMI 22.7 normal"-style text using it.

Difficulty: beginner

Back to lesson: Practice: Practice: Utility Library