Chapter 3 Programming Challenges 3)- Body Mass Index Write a program that calcul
ID: 3585440 • Letter: C
Question
Chapter 3 Programming Challenges 3)- Body Mass Index Write a program that calculates and displays a person's body mass index (BMI), The BM is often used to 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 where weight is measured in pounds and height is measured in inches. The program should display a message indicating whether a person has optimal weight, is underweight, or is overweight. A sedentary person's BMI is considered optimal if his or her BMI is between 18.5 and 25. If the BMI is less than 18.5, the person is considered underweight. If the BMI is greater than 25, the person is considered overweight.Explanation / Answer
BMITest.java
import java.util.Scanner;
public class BMITest {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
System.out.println("Enter the weight: ");
double weight = scan.nextDouble();
System.out.println("Enter the height: ");
double height = scan.nextDouble();
double BMI = (weight * 703)/height;
if(BMI > 25) {
System.out.println("overweight");
} else if(BMI >18.5 && BMI <=25) {
System.out.println("optimal");
} else {
System.out.println("underweight");
}
}
}
Output:
Enter the weight:
100
Enter the height:
5.6
overweight
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.