import java.io.*;
public class Feet2Meters {
public static final double feet2meters = 0.305;
// Define a static method that converts feet to meters
public static double convert(double feet)
{
return feet * feet2meters;
}
// Define a main method to test the class
public static void main(String[] args)
{
// initialize a variable called 'feet'
double feet = 100;
/*
initialize a variable called 'meters' that holds the
returning value of the convert() method
*/
double meters = Feet2Meters.convert(feet);
// output
System.out.println(feet +" feet is "+ meters +" meters.");
}
}
I have gotten this far with the code and it works. This does not solve my problem. I need to have the user input the feet and then convert it into meters. The code I posted tells you that 100 feet = 30.5 meters. The amount of feet is already embedded in the code. I figure I just need to build off this but I'm not sure where to go from here.
Does this make sense? I am taking this class to learn the language. I am a web designer by trade and have limited programing experience. I hand code my sites and I am fluent in html, xml, actionscript, and css. Java is new to me. Thank you for your help.
milam.matthew@gmail.com

New Topic/Question
Reply




MultiQuote





|