Advertisement
mbazs

Calc BMI short

Nov 21st, 2018
473
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.34 KB | None | 0 0
  1. for (int i = 0; i < names.length; ++i) {
  2.     if (name.equalsIgnoreCase(names[i])) {
  3.         double bmi = weight[i] / (height[i] * height[i]);
  4.         String bodyType = (bmi < 18.5 ? "underweight" : (bmi < 25 ? "normal" : (bmi < 30 ? "overweight" : "obese")));
  5.         System.out.println(name + " is " + bodyType + ", BMI index = " + bmi);
  6.     }
  7. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement