Results 1 to 5 of 5

Thread: Program Help!

  1. #1
    Keno777 is offline Member
    Join Date
    Oct 2009
    Posts
    27
    Rep Power
    0

    Default Program Help!

    The first part of this program I have to write I have successfully completed.
    Below I have already done and its working.


    Implement the following static methods in the TemperatureConverter class:

    * celsiusToFahrenheit which should take a celsius temperature as an explicit parameter and which should return the fahrenheit equivalent.
    * fahrenheitToCelsius which should take a fahrenheit temperature as an explicit parameter and which should return its celsius equivalent.
    * celsiusToKelvin which should convert a celsius temperature to kelvin.
    * kelvinToCelsius which should convert a kelvin temperature to celsius.
    * fahrenheitToKelvin which should convert from fahrenheit to kelvin.
    * kelvinToFahrenheit which should convert from kelvin to fahrenheit.
    * celsiusToRankine which should convert a celsius temperature to its rankine equivalent.
    * rankineToCelsius which should convert from rankine to celsius.
    * fahrenheitToRankine which should convert from fahrenheit to rankine.
    * rankineToFahrenheit which should convert from rankine to fahrenheit
    * kelvinToRankine which should convert from kelvin to rankine
    * rankineToKelvin which should convert from rankine to kelvin.


    All the above I have currently done. Below is the part I am having trouble with putting together.

    The instructions read....
    # We will be getting input from the user in this test program, so we will need a Scanner object.
    # Ask the user to enter a Celsius temperature. Then use your Scanner object to read in their response as a value of type double.
    # Convert the temeprature they enter from Celsius to the other 3 scales using your static methods of your TemperatureConverter class to do this. You call a static method with: ClassName.methodName(parameters).


    The following code is what I have, but i cannot quite figure out how to implement my static methods to take the number entered in by the user and convert them.




    public class TemperatureTester
    {


    public static void main(String[] args)
    {

    String celsiusEnter = ("Please enter a Celsius temperature");

    Scanner input = new Scanner(System.in);
    System.out.println(celsiusEnter);
    double celsiusnumber = input.nextDouble();

    celsiusnumber.TemperatureConverter.celsiusToFahren heit(double celsius)

    The last syntax part is where I am stuck. I have not really a clue on how to implement what I need there. I have tried a mixture of things but nothing works. Any help or a point in the right direction would be great. Not looking for someone to do my work, just help me. Thanks

  2. #2
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    7

    Default

    Java Code:
    double fValue = TemperatureConverter.celsiusToFahren heit(celsiusnumber );
    You are no longer declaring the methods. You are now calling them. When calling a method you don't pass the type of the parameter. Just the value which in this case you have taken from the user already and put into celsiusnumber .

  3. #3
    Keno777 is offline Member
    Join Date
    Oct 2009
    Posts
    27
    Rep Power
    0

    Default

    Ahh that makes a lot of sense I cannot believe I did not see that. Thank you very much! I am guessing i would just have to use the System.out.print method to print the final result(you named it (fvalue)

  4. #4
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    7

    Default

    I'm bad with names. See my user name for an example.

  5. #5
    Keno777 is offline Member
    Join Date
    Oct 2009
    Posts
    27
    Rep Power
    0

Similar Threads

  1. Execute A program from a Program!
    By Moncleared in forum Advanced Java
    Replies: 2
    Last Post: 02-22-2009, 04:17 PM
  2. Executing a program within a program
    By gibsonrocker800 in forum New To Java
    Replies: 5
    Last Post: 05-12-2008, 08:24 AM
  3. Replies: 0
    Last Post: 04-04-2008, 02:40 PM
  4. Replies: 0
    Last Post: 10-04-2007, 09:33 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
  •