Question

In: Computer Science

Using class, write a program that: Body Mass Index (BMI) calculation - write a program that...

Using class, write a program that:

  • Body Mass Index (BMI) calculation - write a program 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)
  • Convert the BMI program to Object Oriented (have two files – main class file and BMI class file)
  • in java please

Solutions

Expert Solution

Answer:

Here is the java code as per your requirement

Raw code:

filename: BMI.java

//BMI Class file

public class BMI{

//method to calculate bmi

public void calculateBmi(double height,double weight){

//declaring variable

double bmi;

//bmi formula

bmi=703*weight/(height*height);

//calculating bmi based on formula

if(bmi<18.5){

System.out.println("You are underweight");

}

else if(bmi>18.5){

System.out.println("You have a normal weight");

}

else if(bmi>24.9){

System.out.println("Your weight is considered overweight");

}

else if(bmi>30){

System.out.println("your weight is considered as obese");

}

}

}

Editor:

Filename: Main.java

// importing Scanner class

import java.util.Scanner;

//main

class Main {

//main method

public static void main(String[] args) {

//Scanner object

Scanner sc = new Scanner(System.in);

//declaring variables

int weight,height;

//asking user for height and weight

System.out.print("Enter height(in): ");

height=sc.nextInt();

System.out.print("Enter weight(lbs): ");

weight=sc.nextInt();

//creating BMI object

BMI b = new BMI();

//calling the method of bmi class

b.calculateBmi(height, weight);

}

}

Editor:

output:

Hope this helps you! If you still have any doubts or queries please feel free to comment in the comment section.

"Please refer to the screenshot of the code to understand the indentation of the code".

Thank you! Do upvote.


Related Solutions

The Body Mass Index (BMI) is a calculation used to categorize whether a person’s weight is...
The Body Mass Index (BMI) is a calculation used to categorize whether a person’s weight is at a healthy weight for a given height. The formula is as follows:                 bmi = kilograms / (meters2)                 where kilograms = person’s weight in kilograms, meters = person’s height in meters BMI is then categorized as follows: Classification BMI Range Underweight Less than 18.5 Normal 18.5 or more, but less than 25.0 Overweight 25.0 or more, but less than 30.0 Obese 30.0...
Design a modular program that calculates and displays a person's body mass index (BMI). The BMI...
Design a modular program that calculates and displays a person's body mass index (BMI). The BMI is often used to determine whether a person with a sedentary lifestyle is overweight or underweight for his or her height. A person's BMI is calculated with the following formula: BMI=Weight*703/Height^2. I need help making this to Java to just calculate BMI.
In Java, need to create a program with Body Mass Index (BMI) is a measure of...
In Java, need to create a program with Body Mass Index (BMI) is a measure of health on weight. It can be calculated by taking your weight in kilograms and dividing, by the square of your height in meters. Write a program that prompts the user to enter a weight in pounds and height in inches and displays the BMI. Note one pound is 0.45359237 kilograms and one inch is 0.0254 meters. Here is a sample run: Enter weight in...
Discuss the process of calculating Body Mass Index (BMI).
Discuss the process of calculating Body Mass Index (BMI).
The body mass index​ (BMI) for a sample of men and a sample of women are...
The body mass index​ (BMI) for a sample of men and a sample of women are given below. Assume the samples are simple random samples obtained from populations with normal distributions. Men 30.930.9 22.322.3 29.929.9 30.930.9 27.227.2 31.731.7 26.526.5 20.220.2 26.626.6 30.530.5 Women nbspWomen 18.218.2 20.720.7 22.222.2 28.428.4 17.117.1 20.320.3 23.923.9 31.831.8 20.820.8 20.720.7 LOADING... Click the icon to view the table of​ Chi-Square critical values. a. Construct aa 9090​% confidence interval estimate of the standard deviation of BMIs for...
Complete a 6-step hypothesis test using the following scenario: The body mass index (BMI) of an...
Complete a 6-step hypothesis test using the following scenario: The body mass index (BMI) of an individual is a measure used to judge whether an individual is overweight or not. A BMI between 20 and 25 indicates normal weight. In a survey of 750 men and 750 women, the Gallup organization found that 203 men and 270 women were normal weight. Is this enough evidence to determine if there is a greater number of women at a normal weight than...
Body mass index (BMI) is a reliable indicator of body fat for most children and teens....
Body mass index (BMI) is a reliable indicator of body fat for most children and teens. BMI is calculated from a child’s weight and height and is used as an easy-to-perform method of screening for weight categories that may lead to health problems. For children and teens, BMI is age- and sex-specific and is often referred to as BMI-for-age. The Centers for Disease Control and Prevention (CDC) reports BMI-for-age growth charts for girls as well as boys to obtain a...
We claim that the body mass index (BMI) for men is statistically the same as the...
We claim that the body mass index (BMI) for men is statistically the same as the BMI for women. Data from a random sample of 40 men and 40 women is presented below: BMI-M BMI-F Mean 25.9975 Mean 25.74 Standard Error 0.542448 Standard Error 0.974862 Median 26.2 Median 23.9 Mode 23.8 Mode 19.6 Standard Deviation 3.430742 Standard Deviation 6.16557 Sample Variance 11.76999 Sample Variance 38.01426 Kurtosis -0.13645 Kurtosis 1.517743 Skewness 0.356785 Skewness 1.189501 Range 13.6 Range 27.2 Minimum 19.6 Minimum...
The data file contains the Body Mass Index (BMI) for a sample of men and a...
The data file contains the Body Mass Index (BMI) for a sample of men and a sample of women. Two of the columns, OW_male and OW_female code the BMI values as: 0 - if BMI ≤ 25.4 (these are considered “not overweight”); 1 - if BMI >= 25.5 (these are considered “overweight”). (a) Test whether there is sufficient evidence to show that the proportion of overweight males (proportion of males who are overweight) is different than the proportion of overweight...
If a regression analysis was to be completed on body mass index (BMI), what could be...
If a regression analysis was to be completed on body mass index (BMI), what could be an independent variable in that analysis? Why? If we could, what other independent variables should be included in the analysis? What statistic(s) would show the value of that regression in understanding BMI? Alternatively, find an article that uses regression analysis to study a medical concern. In that study, what was the dependent variable and what was the independent variable(s)? Further, how would you use...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT