Page 2 of 2 FirstFirst 12
Results 21 to 24 of 24
  1. #21
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: methods... SO confused!

    Quote Originally Posted by ertopp View Post
    yes, i do now. sorry. I have been staring at this program for hours.
    With that extra brace and it's sibling end brace down in your program, your calculateCelsius method ends up inside of the main method, and methods cannot be nested within methods -- which is the cause of most of your error messages. Again, compile frequently and fix all compile errors before adding code. Either this or use an IDE such as Eclipse or NetBeans which compiles as you type showing errors as you go.

  2. #22
    ertopp is offline Member
    Join Date
    Oct 2011
    Posts
    22
    Rep Power
    0

    Default Re: methods... SO confused!

    Thank you!
    Last question, I am posting this for the last time because I made changes. But I am now getting one single error -

    public class FahrenheitToCelsius
    {

    public static void main(String[] args)
    {

    float fahrenheit, celsius;
    String input;

    input = JOptionPane.showInputDialog("Enter the Fahrenheit temperature you wish to convert as a floating point number.");
    //Convert the input to float.
    fahrenheit = Float.parseFloat(input);

    celsius = calculateCelsius(fahrenheit);
    JOptionPane.showMessageDialog(fahrenheit + " degrees fahrenheit =" + celsius + " degrees celsius");
    }


    //Calculate Celsius
    public static float calculateCelsius(float f)
    {
    float celsius = (5/9) * (f - 32);
    return celsius;
    }





    }

    The error is : symbol : method showMessageDialog(java.lang.String)
    location: class javax.swing.JOptionPane
    JOptionPane.showMessageDialog(fahrenheit + " degrees fahrenheit =" + celsius + " degrees celsius");

  3. #23
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: methods... SO confused!

    what is the exact error message. Your message is missing text. And when posting code in the forum, please use code tags so its readable. Place the tag [code] above your code block and [/code] below your code block as this will help the code retain its formatting.

  4. #24
    ertopp is offline Member
    Join Date
    Oct 2011
    Posts
    22
    Rep Power
    0

    Default Re: methods... SO confused!

    OH MY GOD! IF I COULD SEE YOU I WOULD GIVE YOU THE BIGGEST HUG, LOL!

    MY PROGRAM RUNS AND IT'S PERFECT!

    I understand it so much better! Thank you for helping me to see that extra brace!
    ahhh, I hear angels singing! thank you thank you!

Page 2 of 2 FirstFirst 12

Similar Threads

  1. Replies: 8
    Last Post: 04-16-2012, 11:00 PM
  2. Replies: 1
    Last Post: 10-05-2011, 12:15 AM
  3. Help i am so confused..:(
    By angeltiner in forum AWT / Swing
    Replies: 6
    Last Post: 04-11-2010, 01:43 AM
  4. Confused
    By coldfire in forum New To Java
    Replies: 3
    Last Post: 01-13-2009, 01:00 PM
  5. what does it mean:confused:
    By sivasayanth in forum New To Java
    Replies: 2
    Last Post: 01-12-2008, 04:52 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •