BMI Calculator

Lab Java Beginner 10 points

Read weight (kg) and height (m). Print the BMI (weight / height²) with 1 decimal, then the category: under 18.5 underweight, under 25 normal, otherwise overweight.

Input

Two decimal numbers.

Output

Two lines.

Example

Input

70 1.75

Output

22.9
normal
Sample input available Sample output available
Editor
Java

Hints

Square the height with height * height.

Solution explanation

Store the result in a variable so you can both print it and test it.

Show solution
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        double weight = sc.nextDouble();
        double height = sc.nextDouble();
        double bmi = weight / (height * height);
        System.out.printf("%.1f%n", bmi);
        if (bmi < 18.5) {
            System.out.println("underweight");
        } else if (bmi < 25) {
            System.out.println("normal");
        } else {
            System.out.println("overweight");
        }
    }
}
Output
Answer
HOME LEARN COMMUNITY DASHBOARD