diff --git a/src/main/java/src/TasksFrame.java b/src/main/java/src/TasksFrame.java index a9c7611..fddb709 100644 --- a/src/main/java/src/TasksFrame.java +++ b/src/main/java/src/TasksFrame.java @@ -147,8 +147,10 @@ public class TasksFrame extends JFrame { } public double bmi(double height, double weight) { - - return weight / (height * height); + double result = 0.0; + result = weight / (height * height); + double roundOff = Math.round(result * 100.0) / 100.0; + return roundOff; } diff --git a/src/test/java/src/TasksFrameTest.java b/src/test/java/src/TasksFrameTest.java index ff2a433..26872fc 100644 --- a/src/test/java/src/TasksFrameTest.java +++ b/src/test/java/src/TasksFrameTest.java @@ -158,6 +158,17 @@ class TasksFrameTest { int c = Integer.parseInt(tasksFrame.umrechnen(48)); assertEquals(110000, c); } + + @Test + void test_bmi(){ + TasksFrame tasksFrame = new TasksFrame(); + double a = tasksFrame.bmi(1.65, 60.0); + assertEquals(22.04, a); + double b = tasksFrame.bmi(1.95, 72); + assertEquals(18.93, b); + double c = tasksFrame.bmi(1.24, 30); + assertEquals(19.51, c); + } }