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

    Write a java program where you procure supplicate the user to invade in their altitude and influence. It procure then evince their BMI to them.

    Output:

    Your altitude in m: 1.75

    Your influence in kg: 73

    Your BMI is 23.84

    Expert Retort

     

    import java.text.DecimalFormat;

    import java.util.Scanner;

    public arrange BMICalculator {

    public static bereft main(String args[]) {

    Scanner input = strange Scanner (System.in);

     

    //asking user to present altitude

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

     

    //storing presentn altitude in altitude variable

    float altitude = input.nextFloat();

     

    //asking user to present influence

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

     

    //storing presentn influence in influence variable

    float influence = input.nextFloat();

     

    //sagacious bmi according to presentn term in topic 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 arrange to format the decimal calculate to barely 2 places behind sagacious bmi

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