aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes bmi calculation help please! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "bmi calculation help please!" Watch "bmi calculation help please!" New topic
Author

bmi calculation help please!

Sarah Ingram
Greenhorn

Joined: Apr 06, 2004
Posts: 8
Hi,
I am trying to create a Body Mass Index page, but keep on getting this same error:
C:\BMI.java:147: int cannot be dereferenced
bmi.setText(""+bmi);
^
1 error

I have tried to sort it but have been unsuccessful. Please can someone help me spot the error(s)! Thanks in advance.
Code is below:
Ted Reynolds
Greenhorn

Joined: Mar 16, 2004
Posts: 20
Sarah,
I got it to wrok by changing the name of the variable you use to do the actual calulation to bmiValue. My theory on why it didn't work the way you had it was that you had a textfield and an integer with the same name and this confused the compiler.
Sarah Ingram
Greenhorn

Joined: Apr 06, 2004
Posts: 8
Thanks very much Ted...you were right about the compiler getting confused with all the similar names. Works just fine now!
Thanks
Eddie Vanda
Ranch Hand

Joined: Mar 18, 2003
Posts: 281
You could have used "this.bmi.setText(""+bmi);" as that it would refer to the class variable bmi.


The nice thing about Standards is that there are so many to choose from!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: bmi calculation help please!