Where weight is the person’s weight in grams and height is their height in centimeters. If the result of this calculation is less that 20, then the person is medically underweight. If the result is greater than 30 then the person is medically overweight. Write a program to calculate whether a given person is underweight or overweight.

You forget to ask any questions about your problem.

import javax.swing.JOptionPane;
public class Bmi {

    public static void main(String[] args) {

    //declare variables

    int height;
    int weight;
    String accept;
    double bmi;
   //Accept the height and weight from user
    accept = JOptionPane.ShowInputDialog("Enter Weight");
    weight = Integer.ParseInt(accept);
    accept = JOptionPane.ShowInputDialog("Enter Height");
    height = Integer.ParseInt(accept);

   //Caculate the BMI with giving formula
   bmi = (10 * weight) / (height * height);

   // Do If statement to make output
   if(bmi < 20)
      JOptionPane.ShowMessageDialog(null,"User is Underweight");
   else if (bmi > 30)
     JOptionPane.ShowMessageDialog(null,"User is Overweight");
    else
     JOptionPane.ShowMessageDialog(null,"User Has a Good Weight+");

    	System.exit(0);
    }
}

its keep showing cannot find symbol method showInputDialog(java.lang.string) and
cannot find symbol method parseInt(java.lang.string

Those sound like compiler errors.

cannot find symbol method showInputDialog(java.lang.string)

The text of the error message you posted does NOT match your code. Case is important in java

cannot find symbol method parseInt(java.lang.string

Same problem here.

When you post error messages it is VERY IMPORTANT that you copy and paste them as they came from the compiler vs typing in something that is similar.

Java names are case-sensitive. Method names in the API begin with a lower case letter. Check your method names for capital vs lower case against the API reference.

its still the same...can you run it on your laptop..thanks and checked it for me...

Please copy and post the full text of the error message here.

its still the same...can you run it on your laptop..thanks and checked it for me...

yep, your code runs just fine, you just need to use the correct upper and lower cases, as was suggested earlier.

After I fix the spelling errors it runs fine for me. I don't get any errors.

Next time please use the code tags

Your code with fixed cases:

import javax.swing.JOptionPane;



public class Bmi {

	public static void main(String[] args) {

		//declare variables

		int height;
		int weight;
		String accept;
		double bmi;
		//Accept the height and weight from user
		accept = JOptionPane.showInputDialog("Enter Weight");
		weight = Integer.parseInt(accept);
		accept = JOptionPane.showInputDialog("Enter Height");
		height = Integer.parseInt(accept);

		//Caculate the BMI with giving formula
		bmi = (10 * weight) / (height * height);

		// Do If statement to make output
		if(bmi < 20)
			JOptionPane.showMessageDialog(null,"User is Underweight");
		else if (bmi > 30)
			JOptionPane.showMessageDialog(null,"User is Overweight");
		else
			JOptionPane.showMessageDialog(null,"User Has a Good Weight+");

		System.exit(0);
	}
}
commented: Why do the OPs homework? -3

thanks alots...its work now..i appreciate it alots

@andersonelnino DO NOT create multiple posts with same question, just because you are not getting answer fast enough. This is not 24/7 support for lazy students

For these wishing to follow this "enlightening" discussion can do so here.

Thread closed.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.