**BMI Calculation of each person in Array
**

Place the three arrays – age, weight, height, and names in the main method. Pass the weight and height arrays into a method called calculate. Within the calculate method, write code to compute the BMI of each person. Compute and return the number of people who weigh optimally back into the main method and print it.

BMI = 703 * weight / height2

For optimal weight, 18.5 <= BMI < 25

int []weight = {125, 210, 150, 140, 180, 225, 175, 110, 145, 170, 195, 190};

int []height = {65, 67, 72, 66, 70, 68, 69, 70, 66, 69, 69, 75};

**Solution:**

```
import java.text.MessageFormat;
public class Main {
public static void main(String[] args) {
int []age = {18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18};
int []weight = {125, 210, 150, 140, 180, 225, 175, 110, 145, 170, 195, 190};
int []height = {65, 67, 72, 66, 70, 68, 69, 70, 66, 69, 69, 75};
int n = 12;
int opt = calculate(weight, height);
System.out.println(MessageFormat.format("Number of persons with optimal weight: {0}/{1}", opt, n));
}
private static int calculate(int[] weight, int[] height) {
int counter = 0;
for (int i = 0; i< weight.length; i++) {
double bmi = 703.0 * weight[i] / (height[i] * height[i]);
if (bmi >= 18.5 && bmi < 25) {
counter++;
}
}
return counter;
}
}
```