72.3k views
7 votes
an individual’s Body Mass Index (BMI) is a measure of a person’s weight in relation to their height. it is calculated as follows: • divide a person’s weight (in kg) by the square of their height (in meters) design and implement a program to allow the user to enter their weight and height and then print out their BMI by using java

1 Answer

5 votes

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);

}

}

Step-by-step 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);

User Gypsa
by
7.9k points