In the following statement, I get an error on line 30. Could you please tell me who knows?
import java.util.Scanner;
class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in);
System.out.println ("name:"); String firstName = scanner.next(); System.out.println ("Last Name:"); String lastName = scanner.next(); System.out.println ("age:"); int age = scanner.nextInt(); System.out.println ("height (m):"); double height = scanner.nextDouble(); System.out.println ("Weight (kg):"); double weight = scanner.nextDouble();
sub(firstName,lastName,age,height,weight);
}
public static void sub(String firstName, String lastName, int age, double height, double weight) { System.out.println ("Name is" + firstName + "" + lastName + "); System.out.println ("Age is" + age + "years"); if (age> = 20) {System.out.println ("adult");} else {System.out.println ("Minor");} System.out.println ("height is" + height + "m"); System.out.println ("Weight is" + weight + "kg"); System.out.println ("BMI is" + Math.round (bmi (weight, height)) + ""); ☆ if (isHealthy (bmi)) {System.out.println ("healthy");} else {System.out.println ("not healthy");}
}
public static double bmi(double weight, double height){ return weight / height / height; }
public static boolean isHealthy(double bmi){ return bmi>=18.5&&bmi<25;
}
}
Recommended Posts