Answer:
import java.util.*;
public class Main
{
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
float weight, height,bmi;
System.out.print("Enter weight (kg) and height(m): ");
weight = input.nextFloat();
height = input.nextFloat();
bmi = (weight)/(height*height);
System.out.print("BMI: "+bmi);
}
}
Explanation:
This declares all variables as float
float weight, height,bmi;
This prompts the user to enter weight and height
System.out.print("Enter weight (kg) and height(m): ");
This next two lines get input from the user for weight and height
weight = input.nextFloat();
height = input.nextFloat();
This calculates the bmi
bmi = (weight)/(height*height);
This prints the bmi
System.out.print("BMI: "+bmi);