The Body Mass Index (BMI) is the ratio of the weight of a person(in kilograms) to the square of the height(in meters)Formula To Calculate Body Mass Index (BMI)BMI = weight / (height x height);Write a JavaScript program that calculates the BMI, and reports the BMI category as per the following table:BMI Category BMIUnderweight below 18.5Healthy 18.6 to 24.9Overweight 25 to 25.9Obese Obese 30 or greaterInput Data
Question
The Body Mass Index (BMI) is the ratio of the weight of a person(in kilograms) to the square of the height(in meters)Formula To Calculate Body Mass Index (BMI)BMI = weight / (height x height);Write a JavaScript program that calculates the BMI, and reports the BMI category as per the following table:BMI Category BMIUnderweight below 18.5Healthy 18.6 to 24.9Overweight 25 to 25.9Obese Obese 30 or greaterInput Data
Solution
Here is a simple JavaScript program that calculates the BMI and reports the BMI category:
function calculateBMI(weight, height) {
var bmi = weight / (height * height);
var category = "";
if (bmi < 18.5) {
category = "Underweight";
} else if (bmi >= 18.5 && bmi <= 24.9) {
category = "Healthy";
} else if (bmi >= 25 && bmi <= 29.9) {
category = "Overweight";
} else {
category = "Obese";
}
return "Your BMI is " + bmi.toFixed(2) + " and you are " + category;
}
console.log(calculateBMI(70, 1.75)); // Example usage
In this program, we first calculate the BMI using the provided formula. Then, we use a series of if-else statements to determine the BMI category based on the calculated BMI. The function then returns a string that includes the calculated BMI (rounded to two decimal places using the toFixed method) and the BMI category. The console.log statement at the end is an example of how to use the function, and it will print the result to the console.
Similar Questions
Body Mass Index (BMI) is a way of finding out if a person’s body mass falls within a healthy range for their height. Table 1 shows information about two people.Table 1 Person Body mass in kg Height in m BMI in kg/m 2 A631.6523.1 B921.71X The graph below shows five BMI categories for adults. 1. Page 2 of 19(a) Which is the BMI category of person A in Table 1? Tick (✓ ✓ ✓ ✓) one box.Clinically obese Normal Obese Overweight Underweight (1) (b) Calculate value X in Table 1. Use the equation: Give your answer to 3 significant figures. ___________________________________________________________________ ___________________________________________________________________ ___________________________________________________________________ ___________________________________________________________________ ___________________________________________________________________ ___________________________________________________________________ X = _______________ kg/m 2 (3) Page 3 of 19Scientists think there is a link between BMI and life expectancy. Table 2 shows information about predicted life expectancy of men after the age of 50.Table 2 BMI Category Predicted number of years living in good health after the age of 50 Predicted number of years living in bad health after the age of 50 Normal19.064.98 Overweight18.685.32 Obese16.377.08 Clinically obese13.0710.10 (c) Describe two patterns shown in Table 2 about the effects of BMI category. 1 ________________________________________________________________ ___________________________________________________________________ ___________________________________________________________________ 2 ________________________________________________________________ ___________________________________________________________________ ___________________________________________________________________ (2) The number of people who are obese in the UK is increasing. (d) Explain the financial impact on the UK economy of an increasing number of people who are obese. ___________________________________________________________________ ___________________________________________________________________ ___________________________________________________________________ ___________________________________________________________________ (2) Page 4 of 19(e) A person who is obese is more at risk of arthritis. Arthritis is a condition that damages joints. Suggest how arthritis could affect a person’s lifestyle. ___________________________________________________________________ ___________________________________________________________________ (1) (f) A person who eats a diet high in saturated fat might become obese. Name two health conditions that might develop if a person eats a diet high in saturated fat. Do not refer to arthritis in your answer. 1 ________________________________________________________________ 2 ________________________________________________________________
Given height and weight of a person in float, calculate Body Mass index of the person and print respective output based on calculation. Formulae for calculation: [weight (kg) / height (cm) / height (cm)] x 10,000 .For Example: weight =76.7 , height=162.2 BMI=((76.7/162.2)/162.2)X 10,000BMI=(0.4728/162.2)X 10,000 BMI=0.000291X 10,000 BMI=29.1 So, it is Overweight.Print "Underweight" or "Healthy weight" or "Overweight" or "Obesity". Below 18.5 Underweight 18.5 – 24.9 Healthy weight 25.0 – 29.9 Overweight 30.0 and Above ObesityInput Format:Accept two inputs, weight(float) and height(float)Output Format:Print "Underweight" or "Healthyweight" or "Overweight" or "Obesity"Constraints:1<=N<=10^15Sample Input 1:46.5 165.3Sample Output 1:UnderweightSample Input 2:76.7 162.2Sample Output 2:Overweight
Consider you are working in the Hospital and find the Obesity of outpatients, which you need to check Body Mass Index (BMI) for each customer and BMI is found by taking your weight in kilograms and dividing by the square of your height in meters. The BMI categories are:• Under weight: <18.5• Normal weight: 18.5–24.9• Over weight: 25–29.9• Obesity: BMI of 30 or greaterUse class, object, constructor, attributes, and methods.( 1 inch=2.5 cm) Testcase Input 1:Raja5564.96OutputNormal weight
BMI CalculatorCreate an application which calculates BMI (Body Mass Index)Your app should have 2 input boxesTake weight in kgs from userTake height in meters from userBased on entered height and weight calculate BMI of that personHere is the formula for manually calculating BMI BMI = (weight) / (height * height)From the obtained BMI result, display whether the person isUnderWeight - bmi <= 18.4Normal Weight - bmi >= 18.5 && bmi <= 24.9Overweight - bmi >= 25 && bmi <= 29.9Obese - bmi >= 30Hint: use If conditionsSample Output
BMI or body mass index is a health tool used to assess potential health risks from body weight.TrueFalseQuestion 1
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.