Results 1 to 3 of 3

Thread: Get method

  1. #1
    Reiyn is offline Member
    Join Date
    Sep 2008
    Posts
    29
    Rep Power
    0

    Default Get method

    Hello, I'm taking a Java class, and am having trouble getting my get method to work in this simple program converting from farenheit to celsius...I'd rather not have the code written for me, just point to the problem please. It is not liking my Get line...
    [code]import javax.swing.*;

    public class Temperature {

    private String sUserTemperature;
    private double iTemp;
    double iConverted = (5/9) * (iTemp - 32);
    double Celsius;
    //double dCelsius = Celsius;

    void SetTemperatureF()
    {
    sUserTemperature = JOptionPane.showInputDialog("Enter farenheit temperature to convert");
    iTemp = Double.parseDouble(sUserTemperature);
    JOptionPane.showMessageDialog( null, "You entered " + iTemp);
    }

    double GetTemperatureF(double iConverted)
    {
    JOptionPane.showMessageDialog(null, iTemp + " equals " + iConverted + " in Celsius." );
    Celsius = iConverted;
    return Celsius;
    }

    My MAIN:
    public class Main {

    /**
    * @param args the command line arguments
    */
    public static void main(String[] args) {


    Temperature oTemp;
    oTemp = new Temperature();
    oTemp.SetTemperatureF();
    oTemp.GetTemperatureF(Celsius);

    }

    Thanks!

  2. #2
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,458
    Rep Power
    25

    Default

    having trouble getting my get method to work
    What does that mean?
    Compiler error? Execution error? Wrong output?
    When you get errors, copy and paste the FULL TEXT here.

  3. #3
    Reiyn is offline Member
    Join Date
    Sep 2008
    Posts
    29
    Rep Power
    0

    Default

    Ok Norm I'llbe sure to do that...I have it now - I hadn't instantiated iConverted in my Main but was using it in my GetTemperatureF inside my Temperature class.
    I hope I said that right.
    Thanks though!

Similar Threads

  1. Replies: 2
    Last Post: 03-26-2010, 05:12 PM
  2. Replies: 29
    Last Post: 09-25-2008, 07:55 PM
  3. cannot call private method from static method
    By jon80 in forum New To Java
    Replies: 3
    Last Post: 05-07-2008, 08:37 AM
  4. Method Help
    By pringle in forum New To Java
    Replies: 4
    Last Post: 04-16-2008, 01:23 PM
  5. flush method
    By bugger in forum New To Java
    Replies: 0
    Last Post: 11-11-2007, 07:39 PM

Posting Permissions

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