The program below is the answer to Deitel’s Java How to Program (9th Edition) Chapter 2 Exercise 2.33.
Click here to see other answers to Java How to Program.
Question: The Formulas for calculating BMI are:
Create a BMI calculator that reads the user’s weight in pounds and height in inches (or, if you prefer, the user’s weight in kilograms and height in meters), then calculates and displays the user’s body mass index. Also, display the following information from the Department of Health and Human Services/National Institutes of Health so the user can evaluate his/her BMI:
BMI VALUES
Underweight: less than 18.5
Normal: between 18.5 and 24.9
Overweight: between 25 and 29.9
Obese: 30 or greater
1 2 |
/**<br /> *<br /> * @Author: Aghatise Osazuwa<br /> * Website: www.cscprogrammingtutorials.com<br /> *<br /> * Exercise 2.33 - Body Mass Index Calculator<br /> * This Program Calculates And Displays A User's Body Mass Index (BMI)<br /> *<br /> */ <br /><br />import java.util.Scanner;<br /><br />public class Ex02_33 {<br /> public static void main (String [] args) {<br /><br /> Scanner input = new Scanner (System.in);<br /> <br /> int weight;<br /> int height;<br /> int bMI;<br /> <br /> System.out.print ("Enter Your Weight in Pounds: ");<br /> weight = input.nextInt();<br /> System.out.print ("Enter Your Height in Inches: ");<br /> height = input.nextInt();<br /> bMI = (weight * 703) / (height * height);<br /> System.out.printf ("Your Body Mass Index (BMI) is %dnn", bMI);<br /> <br /> System.out.println ("BMI VALUES");<br /> System.out.println ("Underweight: less than 18.5");<br /> System.out.println ("Normal: between 18.5 and 24.9");<br /> System.out.println ("Overweight: between 25 and 29.9");<br /> System.out.println ("Obese: 30 or greater");<br /><br /> }<br />}<br /> |
Click here to see other answers to Java How to Program.
3 Comments
simple code but i think it's very useful for other that need this, especially for a student that studying java
Hi 5faya,
If you understood the program above, I think you should be able to solve the problem yourself. Its just knowing the right formula and converting it to a java program or any other programming language.
If you cannot solve it after trying it yourself, tell me the formula for calculating BFI and then I can help you.
define application that compute person Body Fat Index “BFI”
Do you have a solution for this problem ?