# Program Help!

Printable View

• 10-16-2009, 09:45 PM
Keno777
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
• 10-16-2009, 09:49 PM
r035198x
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 .
• 10-16-2009, 10:12 PM
Keno777
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)
• 10-16-2009, 10:18 PM
r035198x
I'm bad with names. See my user name for an example.
• 10-16-2009, 10:51 PM
Keno777
haha, thanks again!