Write a java program that asks a person for his height (in meters) and weight (in kilograms) and
outputs one of the messages: underweight, normal, or obese, using the BMI formula and BMI
classification. Body Mass Index (BMI) is an index used to measure the body fat using the height
and weight of a person.
BMI Formula:
BMI = (Weight in Kilograms / (Height in Meters x Height in Meters))
BMI Classification:
Underweight: BMI <= 18.4
Normal: 18.5 < =BMI < =24.99
Overweight: 25 < =BMI

how can i do that in netbeans ??

Recommended Answers

All 7 Replies

What have you done?

Please note our member rules, including

Do provide evidence of having done some work yourself if posting questions from school or work assignments

what do you mean what i have done ??

this is the question and i don't know how to solve it :(

It appears you are in a course that just handed you an assignment or "homework." The course should work its way up to this moment. That is, if you weren't paying attention before, what you are assigned may be Greek to you.

Go back over the material before this to see what you missed.

Just thinking. By now in your course you should be able to create the first part of the assignment which is:
"Write a java program that asks a person for his height (in meters) and weight (in kilograms)"

Did you get that far? If not, time to go back over the course to see where that was omitted, forgotten.

Really Interesting task actually

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");

    }
}

I have found it on internet!

When i was starting programming i was strugling with these problems... i didnt understanded the given task... i hope you will learn something from this code and try to write in your way. Am waiting reply with your own method for this task. Since if you show this code they will know its copied from internet.

commented: Ha,ha I would have used 666 instead of 703! +15

really thanks alot my teacher don't even bother even teach :(

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.