Browse Source

BMI Wert auf Zwei Nachkommastellen abrunden + Test "BMI"

remotes/origin/develop
fdai6040 2 years ago
parent
commit
b028f8100a
  1. 6
      src/main/java/src/TasksFrame.java
  2. 11
      src/test/java/src/TasksFrameTest.java

6
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;
}

11
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);
}
}

Loading…
Cancel
Save