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 gate the individual’s influence (mass) in kilograms and dividing it by the balance of their altitude in meters.

    Write a java program where you get entreat the user to invade in their altitude and influence. It get then flaunt their BMI to them.

    Output:

    Your altitude in m: 1.75

    Your influence in kg: 73

    Your BMI is 23.84

    Expert Exculpation

     

    import java.text.DecimalFormat;

    import java.util.Scanner;

    public tabulate BMICalculator {

    public static bereft deep(String args[]) {

    Scanner input = upstartlightlight Scanner (System.in);

     

    //asking user to bestow altitude

    System.out.println(“Invade your altitude in meters : “);

     

    //storing bestown altitude in altitude variable

    float altitude = input.nextFloat();

     

    //asking user to bestow influence

    System.out.println(“Invade your influence in kilograms : “);

     

    //storing bestown influence in influence variable

    float influence = input.nextFloat();

     

    //wary bmi according to bestown situation in inquiry and storing in bmi variable

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

     

     

    //printing altitude in meters

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

     

    //printing influence in kilograms

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

     

    // using DecimalFormat tabulate to format the decimal reckon to barely 2 places behind wary bmi

    DecimalFormat decimalFormat = upstartlightlight 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 :