Body Mass Index (BMI) Calculator in Java

(Body Mass Index Calculator) We introduced the body mass index (BMI) calculator in
Exercise 1.10. The formulas for calculating BMI are
or
Create a BMI calculator that reads the user’s weight in pounds and height in inches (or, if you prefer, the user’s weight in kilograms and height in meters), then calculates and displays the user’s
body mass index. Also, display the following information from the Department of Health and
Human Services/National Institutes of Health so the user can evaluate his/her BMI:

Body Mass Index (BMI) Calculator in Java

/*
 *       Filename:  BMICalculator.java
 *
 *    Description:  Exercise 2.33 - Body Mass Index Calculator
 *
 *@Author:  Bilal Tahir Khan Meo
 *  Website: https://codeblah.com
 *
 * =====================================================================================
 */
import java.util.Scanner;

public class BMICalculator{
    public static void main(String[] args){
        Scanner input = new Scanner(System.in);

        double weight, height, bmi;
        int choice;

        System.out.print("BMI calculator: 1 for imperial, 2 for metric: ");
        choice = input.nextInt();

        System.out.printf("Input weight in %s: ",
                (choice == 1) ? "pounds" : "kilograms");
        weight = input.nextDouble();

        System.out.printf("Input height in %s: ",
                (choice == 1) ? "inches(ft * 12 * in)" : "metres");
        height = input.nextDouble();

        bmi = (choice == 1) ? calculateImperial(weight, height) : calculateMetric(weight, height);

        System.out.printf("Your BMI : %.1f\n", bmi);
        printBmiTable();
    }

    // calculate using imperial measures
    private static double calculateImperial(double weight, double height){
        return ((weight * 700) / (height * height));
    }
    // calculate using metric measures
    private static double calculateMetric(double weight, double height){
        return weight / (height * height);
    }
    // print BMI information from Department of Health and Human Services /
    // National Institutes of Health.
    private static void printBmiTable(){
        System.out.printf("BMI VALUES:");
        System.out.println("Underweight: less than 18.5");
        System.out.println("Normal:      between 18.5 and 24.9");
        System.out.println("Overweight:  between 25 and 29.9");
        System.out.println("Obese:       30 or greater");
    }
}

Create a BMI Body Mass Index Calculator

/**
 *
 *@Author:  Bilal Tahir Khan Meo
 *  Website: https://codeblah.com
 *
 * Exercise 2.33 - Body Mass Index Calculator
 * This Program Calculates And Displays A User's Body Mass Index (BMI)
 *
 */
 
import java.util.Scanner;
 
public class Ex02_33 {
    public static void main (String [] args) {
 
        Scanner input = new Scanner (System.in);
         
        int weight;
        int height;
        int bMI;
         
        System.out.print ("Enter Your Weight in Pounds: ");
        weight = input.nextInt();
        System.out.print ("Enter Your Height in Inches: ");
        height = input.nextInt();
        bMI = (weight * 703) / (height * height);
        System.out.printf ("Your Body Mass Index (BMI) is %d\n\n", bMI);
         
        System.out.println ("BMI VALUES");
        System.out.println ("Underweight: less than 18.5");
        System.out.println ("Normal:      between 18.5 and 24.9");
        System.out.println ("Overweight:  between 25 and 29.9");
        System.out.println ("Obese:       30 or greater");
 
    }
}