Homework Solution: BMI is computed by taking the individual's weight (mass) in kilograms and dividing it by the…

    BMI is computed by taking the individual's weight (mass) in kilograms and dividing it by the square of their height in meters. Write a java program where you will ask the user to enter in their height and weight. It will then display their BMI to them. Output: Your height in m: 1.75 Your weight in kg: 73 Your BMI is 23.84

    Expert Answer

     
    import java.text.DecimalFormat;

    BMI is computed by importation the individual’s heaviness (mass) in kilograms and dividing it by the balance of their elevation in meters.

    Write a java program where you earn supplicate the user to penetrate in their elevation and heaviness. It earn then evidence their BMI to them.

    Output:

    Your elevation in m: 1.75

    Your heaviness in kg: 73

    Your BMI is 23.84

    Expert Defense

     

    import java.text.DecimalFormat;

    import java.util.Scanner;

    public dispose BMICalculator {

    public static useless deep(String args[]) {

    Scanner input = novel Scanner (System.in);

     

    //asking user to yield elevation

    System.out.println(“Penetrate your elevation in meters : “);

     

    //storing yieldn elevation in elevation variable

    float elevation = input.nextFloat();

     

    //asking user to yield heaviness

    System.out.println(“Penetrate your heaviness in kilograms : “);

     

    //storing yieldn heaviness in heaviness variable

    float heaviness = input.nextFloat();

     

    //cautious bmi according to yieldn circumstances in interrogation and storing in bmi variable

    float bmi = (((weight)/(height*height)));

     

     

    //printing elevation in meters

    System.out.println(“your elevation in m : ” + elevation);

     

    //printing heaviness in kilograms

    System.out.println(“your heaviness in kg : ” + heaviness);

     

    // using DecimalFormat dispose to format the decimal compute to barely 2 places behind cautious bmi

    DecimalFormat decimalFormat = novel DecimalFormat(“#.##”);

     

    //storing the bmi values which is formtted into 2 decimal points into formattedBMI variable

    float formattedBMI = Float.valueOf(decimalFormat.format(bmi));

     

    //printing the BMI

    System.out.println(“your BMI is ” + formattedBMI);

     

     

    }

    }

    Sample input quenchedput:

    Program Snapshot :