Results 1 to 5 of 5
Thread: Program Help!
- 10-16-2009, 09:45 PM #1
Member
- Join Date
- Oct 2009
- Posts
- 27
- Rep Power
- 0
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 #2
Senior Member
- Join Date
- Aug 2009
- Posts
- 2,388
- Rep Power
- 6
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 .Java Code:double fValue = TemperatureConverter.celsiusToFahren heit(celsiusnumber );
- 10-16-2009, 10:12 PM #3
Member
- Join Date
- Oct 2009
- Posts
- 27
- Rep Power
- 0
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 #4
Senior Member
- Join Date
- Aug 2009
- Posts
- 2,388
- Rep Power
- 6
I'm bad with names. See my user name for an example.
- 10-16-2009, 10:51 PM #5
Member
- Join Date
- Oct 2009
- Posts
- 27
- Rep Power
- 0
Similar Threads
-
Execute A program from a Program!
By Moncleared in forum Advanced JavaReplies: 2Last Post: 02-22-2009, 04:17 PM -
Executing a program within a program
By gibsonrocker800 in forum New To JavaReplies: 5Last Post: 05-12-2008, 08:24 AM -
How to execute an External Program through Java program
By Java Tip in forum java.ioReplies: 0Last Post: 04-04-2008, 02:40 PM -
How to execute an External Program through Java program
By JavaBean in forum Java TipReplies: 0Last Post: 10-04-2007, 09:33 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks