Question

BMI Class. Using JAVA write Object Oriented Programming by creating class, object and method , that...

BMI Class. Using JAVA write Object Oriented Programming by creating class, object and method , that takes users' input (weight and Height) and calculates the BMI. If the result is less than 18.5 display "you are underweight", if the result is greater than 18.5 display "you have a normal weight", if the result is greater than 24.9 display "your weight is considered overweight", and the result is greater than 30 display "your weight is considered as obese" (BMI = 703 × weight (lbs) / [height (in)]2)

0 0
Add a comment Improve this question Transcribed image text
Answer #1

public class BMI {

    private double weight;
    private double inches;

    public BMI(double weight, double inches) {
        this.weight = weight;
        this.inches = inches;
    }

    public double getBMI() {
        return (weight / (inches * inches)) * 703;
    }

    public String getStatus() {
        double bmi = getBMI();
        String category;
        if (bmi <= 18.5) {
            category = "you are underweight";
        } else if (bmi < 25) {
            category = "you have a normal weight";
        } else if (bmi < 30) {
            category = "your weight is considered overweight";
        } else {
            category = "your weight is considered as obese";
        }
        return category;
    }
}

import java.util.Scanner;

public class BMICalculation {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        System.out.print("Enter your weight in pounds: ");
        int weight = in.nextInt();
        System.out.print("Enter your height in inches: ");
        double feet = in.nextDouble();
        BMI bmi = new BMI(weight, feet);
        System.out.println("BMI: " + bmi.getBMI());
        System.out.println(bmi.getStatus());
    }
}

Add a comment
Know the answer?
Add Answer to:
BMI Class. Using JAVA write Object Oriented Programming by creating class, object and method , that...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • BMI is often used to determine whether a person with a sedentary lifestyle is overweight or...

    BMI is often used to determine whether a person with a sedentary lifestyle is overweight or underweight for their height. A person’s BMI is calculated with the following formula: BMI = (weight * 703) / height2 In the formula, weight is measured in pounds and height is measured in inches. Create a VB application to calculate a user’s BMI by allowing users to enter their weight and height in the appropriate units. Display their BMI with an appropriate control. Display...

  • Please write this code in C++ Object-Oriented Programming, specify which files are .h, and .cpp, and...

    Please write this code in C++ Object-Oriented Programming, specify which files are .h, and .cpp, and please add comments for the whole code. Include a class diagrams, and explain the approach you used for the project and how you implemented that, briefly in a few sentences. Please note the following: -Names chosen for classes, functions, and variables should effectively convey the purpose and meaning of the named entity. - Code duplication should be avoided by factoring out common code into...

  • Using JAVAFX The application will calculate Body Mass Index (BMI) for people. It must be able...

    Using JAVAFX The application will calculate Body Mass Index (BMI) for people. It must be able to accept as input weights (in pounds or kilos), and height (in inches or centimeters). The application should have a calculate button, and should display the result as well as if the data puts the person in one of 4 categories underweight ( BMI < 18.5) , normal weight (BMI 18.5-24.9), overweight (BMI 25.0 - 29.9) or overweight (BMI > 30) For full credit...

  • python2.7 25 Points. Create a class named BMIGUI with the following behavior. A template has been...

    python2.7 25 Points. Create a class named BMIGUI with the following behavior. A template has been provided for you and you cannot modify the template. You must use grid) to format the interface and you must get as close as possible the layout shown below. The entry box has a width parameter in its constructor you can use to make the box smaller 3. The BMI categories are as follows: Underweight= <18.5 Normal weight18.5-24.9 . Overweight 25-29.9 Obese BMI of...

  • Body Mass Index Calculator

    Create a BMI calculator applications that reads the user's weight in kilograms and height in meters, then calculates and displays the user's body mass index.Also, the application should display the following information from the Department of Health and Human Services, so the user can evaluate his/her BMI:BMI ValuesUnderweight: less that 18.5Normal: between 18.5 and 24.9Overweight: between 25 and 29.9Obese: 30 or greaterFormula for calculating BMI areBMI = weightInKilogramsheightInMeters x heightInMetersThe program is to be written in C++ langauge.I need some...

  • OGICAL 28. Body mass index (BMI) is a measure of obesity. In standard units, it is...

    OGICAL 28. Body mass index (BMI) is a measure of obesity. In standard units, it is calculated by the formula EMENTS BMI = 7032 ATEMENT NESTED INTS where Wis weight in pounds, and His height in inches. The obesity classification is BMI Classification Below 18.5 Underweight 18.5 to 24.9 Normal 25 to 29.9 Overweight 30 and above Obese Tue Write a program in a script file that calculates the BMI of a person. The program asks the person to enter...

  • You are working as a software developer for a large insurance company. Your company is planning...

    You are working as a software developer for a large insurance company. Your company is planning to migrate the existing systems from Visual Basic to Java and this will require new calculations. You will be creating a program that calculates the insurance payment category based on the BMI score. Your Java program should perform the following things: Take the input from the user about the patient name, weight, birthdate, and height. Calculate Body Mass Index. Display person name and BMI...

  • read instructions carefully please matlab only Write a MATLAB function for a BMI calculator that receives the inputs for body weight (lbs)and height (ft) from the user's program, calculates th...

    read instructions carefully please matlab only Write a MATLAB function for a BMI calculator that receives the inputs for body weight (lbs)and height (ft) from the user's program, calculates the BMI using the equation below, displays the BMI category, and outputs the BMI value tothe user's program W (kg) h2 (m2) BMI Display Normal if 18.5 s BMI 25 Display Overweight if 25 s BMI <30 Display Obese if BMI 2 30 Else display underweight So you will create two...

  • I have this C program that calculates an input and converts it to a BMI calculation....

    I have this C program that calculates an input and converts it to a BMI calculation. Any idea how this would look as an LC3 program? I'm taking an LC3 programming class next semester and want an idea of what this code would even translate to, just trying to get a head start. I'm more so curious on how to get user input in a LC3 program, then I can try myself and figure it out from there. int main()...

  • Please solve the following, please type out the code, and do not hand write because its...

    Please solve the following, please type out the code, and do not hand write because its hard to read. I would greatly appreciate it. (JAVA) Problem 1 In a class called H1P1, write a method called bmiOne that takes as arguments a mass in kilograms (a double) and a height in meters (also a double), and returns the body mass index (or BMI) for the given data. If we have mass -m kg and height-h meters, then BMI = Write...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT