If statement part 2 #48 (Underweight? I'm fit as a fiddle.)

Code

/// Name: Amir Salehi
/// Period: 7
/// Program Name: BMI Categories
/// File Name: BMICategories.java
/// Date Finished: 11/4/2015

import java.util.Scanner;

public class BMICategories {

    public static void main(String[] args) {

        Scanner input = new Scanner(System.in);

        double height, weight, bmiValue;
        String category;

        System.out.print("Your height in meters: ");
        height = input.nextDouble();

        System.out.print("Your weight in kilograms: ");
        weight = input.nextDouble();

        bmiValue = weight / Math.pow(height, 2.0d);
        System.out.println("Your BMI is " + bmiValue);

        if (bmiValue <= 18.5) {
            category = "underweight";
        } else if (bmiValue <= 24.9) {
            category = "normal weight";
        } else if (bmiValue <= 29.9) {
            category = "overweight";
        } else {
            category = "obese";
        }

        System.out.println("BMI Category: " + category);

    }

}
    

Picture of the output

Assignment 7

Back to Homepage