Welcome to the Java Programming Forums

The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: BMI Calculator, problem with output

  1. #1
    Junior Member
    Join Date
    Apr 2018
    Thanked 0 Times in 0 Posts

    Default BMI Calculator, problem with output

    Write a Java program to compute body mass index (BMI).

    Test Data
    Input weight in pounds: 452
    Input height in inches: 72

    Expected Output:
    Body Mass Index is 61.30159143458721

    import java.util.Scanner; 
    class RicMain 
        public static void main(String args[]) 
            //formula for body mass index: BMI = (730) * (Weight(w)(in pounds)/height * height(h)(in inches)) 
            Scanner hw = new Scanner(System.in); 
            System.out.print("Enter your height in pounds: "); 
            double h = hw.nextDouble(); 
            System.out.print("Enter your weight in inches: "); 
            double w = hw.nextDouble(); 
            double bmi = ((730 * w) / (h * h)); 
            System.out.println("Your body mass index (BMI) is: " + bmi);  

    There is a problem. When I enter the following after executing the code:
    Enter your height in pounds: 452
    Enter your weight in inches: 72
    Your body mass index (BMI) is: 0.257263685488292 <------This is wrong. What an I doing wrong?

  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Eastern Florida
    Thanked 2,445 Times in 2,396 Posts

    Default Re: BMI Calculator, problem with output

    "Enter your height in pounds:
    Strange. Check the variables.
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member tonya's Avatar
    Join Date
    Feb 2018
    Thanked 1 Time in 1 Post

    Default Re: BMI Calculator, problem with output

    You have entered your weight and height incorrectly (weight is pounds not inches..) plus your maths is wrong is should be:
    BMI = 703 * w / (h * h)

Similar Threads

  1. BMI Calculator, (boolean problem)
    By paco in forum Object Oriented Programming
    Replies: 13
    Last Post: September 22nd, 2014, 01:18 PM
  2. [SOLVED] Java runtime get result output from prompt problem with a larger output in type
    By kingwang98 in forum What's Wrong With My Code?
    Replies: 3
    Last Post: August 14th, 2014, 08:52 AM
  3. BMI calculation
    By dantheman in forum What's Wrong With My Code?
    Replies: 3
    Last Post: August 28th, 2012, 09:57 PM
  4. GUI - calculate BMI (need help asap)
    By jahead in forum What's Wrong With My Code?
    Replies: 1
    Last Post: April 18th, 2011, 04:10 AM
  5. [SOLVED] Another Calculator Problem
    By The_Mexican in forum What's Wrong With My Code?
    Replies: 0
    Last Post: December 4th, 2010, 03:31 PM