• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

New to Programming and need help.

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 79177
377
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic