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.


>> REGISTER NOW TO START POSTING


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

Results 1 to 4 of 4

Thread: BMI calculation

  1. #1
    Junior Member
    Join Date
    Aug 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default BMI calculation

    Hi I am just starting to learn about java.I am trying to calculate BMI of an individual using the JOptionPane.showInputDialog method who I am asking to enter 4 things first name,last name,height in inches and weight in pounds. I want to show the BMI using JOptionPane.showMessageDialog method showing their full name and BMI.What am I doing wrong ?

     
    import javax.swing.JOptionPane;
     
    public class P1 {
     
    	public static void main(String[] args) {
     
    		String FirstName = JOptionPane.showInputDialog("Enter your First name");
    		String LastName = JOptionPane.showInputDialog("Enter your Last name");
    		double height = JOptionPane.showInputDialog("Enter your height in inches");
    		int inches = Integer.parseInt(height);
    		int metre= inches*0.0254;
     
    		double weight =JOptionPane.showInputDialog("Enter your weight in pounds");
    		int pounds = Integer.parseInt(weight);
    		int kilo= pounds/2.2;
     
    		String response=
    				"kilo"*sqrt"metre" +"FirstName"+"Lastname"
     
    		JOptionPane.showMessageDialog(null, response);
    	}
     
    }
    Last edited by helloworld922; August 28th, 2012 at 08:40 PM.


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: BMI calculation

    Also posted at: BMI calculation | DaniWeb
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Super Moderator curmudgeon's Avatar
    Join Date
    Aug 2012
    Posts
    1,130
    My Mood
    Cynical
    Thanks
    64
    Thanked 140 Times in 135 Posts

    Default Re: BMI calculation

    Thanks Norm. He probably got this solved in one of his cross-posts, so there's no need to answer this question.

  4. #4
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,320
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: BMI calculation

    Suggested reading: http://www.javaprogrammingforums.com...s-posting.html

Similar Threads

  1. simulate calculation ?
    By meryqat in forum Java Theory & Questions
    Replies: 3
    Last Post: April 30th, 2012, 01:03 PM
  2. Method for a table for calculation - help!
    By terripwilliams in forum Loops & Control Statements
    Replies: 1
    Last Post: October 26th, 2011, 11:23 AM
  3. I need calculation
    By Swiss518 in forum Loops & Control Statements
    Replies: 7
    Last Post: January 27th, 2011, 01:26 PM
  4. RPM Calculation
    By fobos3 in forum Algorithms & Recursion
    Replies: 2
    Last Post: September 21st, 2010, 08:53 AM
  5. SQL Time Calculation
    By r12ki in forum JDBC & Databases
    Replies: 3
    Last Post: July 31st, 2009, 03:54 AM

Tags for this Thread