52 lines
1.5 KiB
Java
52 lines
1.5 KiB
Java
import java.io.*;
|
|
import java.text.DecimalFormat;
|
|
|
|
public class BMI_BR {
|
|
public static void main(String args[]) throws IOException {
|
|
DecimalFormat antwortFormat = new DecimalFormat("0.0");
|
|
BufferedReader eingabe = new BufferedReader(new InputStreamReader(System.in));
|
|
|
|
String speicher;
|
|
double bmi = 0;
|
|
try {
|
|
System.out.print("Gewicht: ");
|
|
speicher = eingabe.readLine();
|
|
double gewicht = Double.parseDouble(speicher);
|
|
System.out.print("Große: ");
|
|
speicher = eingabe.readLine();
|
|
double grosse = Double.parseDouble(speicher);
|
|
bmi = (gewicht/ (grosse*grosse));
|
|
} catch(NumberFormatException e) {
|
|
System.out.println("Geben Sie Zhal");
|
|
}
|
|
|
|
|
|
|
|
System.out.println("BMI = " + antwortFormat.format(bmi));
|
|
System.out.println("BMI = " + (Math.round(bmi*10.0)/10.0));
|
|
if(bmi < 16) {
|
|
System.out.println("Starkes untergewicht");
|
|
} else if (bmi <= 17) {
|
|
System.out.println("Mäßiges untergewicht");
|
|
}
|
|
else if (bmi <= 18.5) {
|
|
System.out.println("Leichtes untergewicht");
|
|
}
|
|
else if (bmi <= 25) {
|
|
System.out.println("Normalgewicht");
|
|
}
|
|
else if (bmi <= 30) {
|
|
System.out.println("Präadipositas");
|
|
}
|
|
else if (bmi <= 35) {
|
|
System.out.println("Adipositas Grad 1");
|
|
}
|
|
else if (bmi <= 40) {
|
|
System.out.println("Adipositas Grad 2");
|
|
}
|
|
else {
|
|
System.out.println("Adipositas Grad 3");
|
|
}
|
|
}
|
|
|
|
} |