BMI calculator/assessor I've just started with Java. The code below calculates Body Mass Index (BMI).
Could someone look for my code and assess it? Maybe I should write something more? All advice will be very helpful.
import java.util.Scanner;

public class BMI {

    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);

        double weight = 0;
        double height = 0;
        double bmi = 0;

        System.out.println(&quot;Please enter your details to calculate your Body Mass Index.&quot;);

        System.out.println(&quot;Enter your weight in kilograms:&quot;);
        weight = scanner.nextDouble();
        System.out.println(&quot;Enter your height in metres:&quot;);
        height = scanner.nextDouble();
        bmi = (weight / (height * height));
        System.out.println(&quot;Your BMI is: &quot; + bmi);

        if (bmi &gt;= 40) {
            System.out.println(&quot;Serious obesity&quot;);
        } else if (bmi &gt;= 30) {
            System.out.println(&quot;Obesity&quot;);
        } else if (bmi &gt;= 25) {
            System.out.println(&quot;Overweight&quot;);
        } else if (bmi &gt;= 18) {
            System.out.println(&quot;Standard&quot;);
        } else {
            System.out.println(&quot;Underweight&quot;);
        }

        scanner.close();

    }

}
Not bad for a beginner, and I agree with Ben Aaronson's comments. Maybe not now, but when you progress, you should change some things:


Break the code up in logical parts (here: methods), and every part should 
have one and only one task (Single Responsibility Principle). In your 
application, getting the data is one task, calculating is one task and 
displaying the results is one task
Error Handling (see Ben's answer)
Testing! Learn to write JUnit tests! It leads "automatically" to better code, not only because you avoid programming errors, but also because you learn to break up code to make it testable
Make your code both scalable, and applicable in different scenarios. For instance, the if-cascade is easy to write and to understand, but it doesn't scale (what if you need 20 cases?), and it is not freely applicable (e.g. you can't pass it around, the ifs are basically "glued" in place)


Although it might be a little bit too advanced for a beginner: Regarding the last point I want to show you a trick even some senior programmers don't know: 

import java.util.Scanner;
import java.util.TreeMap;

public class BMI {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("Please enter your details to calculate your Body Mass Index.");
        System.out.println("Enter your weight in kilograms:");
        double weight = scanner.nextDouble();
        System.out.println("Enter your height in metres:");
        double height = scanner.nextDouble();
        scanner.close();
        double bmi = weight / (height * height);
        System.out.println("Your BMI is: " + bmi);

        TreeMap&lt;Double, String&gt; map = new TreeMap&lt;&gt;();
        map.put(40.0, "Serious obesity");
        map.put(30.0, "Obesity");
        map.put(25.0, "Overweight");
        map.put(18.0, "Standard");
        map.put(0.0, "Underweight");

        System.out.println(map.floorEntry(bmi).getValue());
    }
}


There is a data structure which can do all the if-checks for you, which makes the code trivial to write, scalable, and easy applicable: A TreeMap. 

A Map is just a kind of dictionary where you can find "stuff" under a given key. In a TreeMap the keys are ordered. In Java's TreeMap you can not only ask for keys, but also for values between the keys, which get rounded up (ceiling...) or down (floor...) to the next key in the map.