I am new to java and my teacher asks me to write a java program about getting the tallest person and the shortest person and their bmi out from a list of input. The input is like(the fist is the number of student and the second number is the height:
4
Diamond 178 55
Jarod 160 80
Douglas 180 60
Rod 151 48
import java.util.*;
public class Measurement {
public static void main(String[] args) {
int n,weight;
double height,tallh,shorh,bmis,bmit;
String nameh,names;
Scanner sc = new Scanner(System.in);
n=sc.nextInt();
String[][] arr= new String[n][3];
for(int i=0;i<n;i++){
String str = sc.nextLine();
String[] s = str.split(" ");
arr[i][0]=s[0];
arr[i][1]=s[1];
arr[i][2]=s[2];
}
tallh=Double.parseDouble(arr[0][1]);
shorh=Double.parseDouble(arr[0][1]);
bmit=0;
bmis=0;
nameh="";
names="";
for(int w=0;w<n;w++){
if(tallh<Double.parseDouble(arr[w][1])){
nameh=arr[w][0];
tallh=Double.parseDouble(arr[w][1]);
bmit=Double.parseDouble(arr[w][2])/Math.pow(tallh/100,2);
}
if(shorh>Double.parseDouble(arr[w][1])){
names=arr[w][0];
shorh=Double.parseDouble(arr[w][1]);
bmis=Double.parseDouble(arr[w][2])/Math.pow(shorh/100,2);
}
}
System.out.printf(names+"is the shortest with BMI equals to %.2f/d",bmis);
System.out.printf(nameh+"is the tallest with BMI equals to %.2f/d",bmit);
}
}
I dont know why I get this error?