• Post Reply Bookmark Topic Watch Topic
  • New Topic

New to Programming and need help.  RSS feed

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am new to Java, programming, and intelliJ. I am trying to make a BMI Calculator using this code as my initial template which converts Fahrenheit to Celsius.








I have came up with the following code for BMI, but I keep getting an error message on the last part of my code.



then:





I get the following error messages:

Error:(19, 22) java: cannot find symbol
symbol: variable height
location: class org.Ten.BMI.BMIButtonListener


Error:(20, 22) java: cannot find symbol
symbol: variable weight
location: class org.Ten.BMI.BMIButtonListener

Error:(28, 9) java: cannot find symbol
symbol: variable resultLabel
location: class org.Ten.BMI.BMIButtonListener

I created a local field within BMIButtonListener for weight, height, resultLabel, and was able to compile but it did not calculate and listed exceptions.

Any help would be greatly appreciated.
 
Marshal
Posts: 56610
172
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

I would suggest you are going about it the wrong way. you should have a TemperatureConverter class with (probably static) fToC and cToF methods and you should be able to run it from the command line so you get this sort of output:
20°C = 68°F
Now, write yourself a BMICalculator class with a bmi method so you can run it from the command line and get output like
If you weigh 47stone 13lb and stand 2′ 10″ tall, your BMI is 408.1
A stone is 14lb and a foot (′) is 12 inches (″).

When you have that sort of thing working you can put a GUI on top of it. You should have a method heading like this
public static double calculateBMI(double weight, double height)
 
Lee Ten
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you! Do you have any suggestions on books or tools to assist with programming? My teacher is no help and I really want to learn more.
 
Campbell Ritchie
Marshal
Posts: 56610
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try Head First Java by Sierra and Bates. You can get the 2nd edition at a very low price second‑hand.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!