In der folgenden Anweisung wird in Zeile 30 ein Fehler angezeigt. Könnten Sie mir bitte sagen, wer weiß?
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 ("Nachname:"); String lastName = scanner.next(); System.out.println ("Alter:"); int age = scanner.nextInt(); System.out.println ("Höhe (m):"); double height = scanner.nextDouble(); System.out.println ("Gewicht (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 ist" + Vorname + "" + Nachname + "); System.out.println ("Alter ist" + Alter + "Jahre"); if (Alter> = 20) {System.out.println ("Erwachsener");} sonst {System.out.println ("Minderjähriger");} System.out.println ("Höhe ist" + Höhe + "m"); System.out.println ("Gewicht ist" + Gewicht + "kg"); System.out.println ("BMI ist" + Math.round (bmi (Gewicht, Größe)) + ""); ☆ if (isHealthy (bmi)) {System.out.println ("gesund");} sonst {System.out.println ("nicht gesund");}
}
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