Answer:
import java.util.*;
public class Main{
public static void main(String [] args){
double height, weight, bmi;
Scanner input = new Scanner(System.in);
System.out.print("Height (m): ");
height = input.nextDouble();
System.out.print("Weight (kg): ");
weight = input.nextDouble();
bmi =weight/(height * height);
System.out.print("BMI: "+bmi);
}
}
Step-by-step explanation:
This line declares height, weight and bmi as double
double height, weight, bmi;
This allows the program gets input from the user
Scanner input = new Scanner(System.in);
This prompts the user for height in meters
System.out.print("Height (m): ");
This gets an input for height
height = input.nextDouble();
This prompts the user for weight in kilogram
System.out.print("Weight (kg): ");
This gets an input for weight
weight = input.nextDouble();
This calculates bmi
bmi =weight/(height * height);
This prints the calculated bmi
System.out.print("BMI: "+bmi);