-2
import java.util.Scanner;

public class feetToMeters {
    public static void main (String [] args) {
        final double feetToMeters = 0.305;
        Scanner input = new Scanner (System.in);

        System.out.println ("Enter a value for feet: ");
        double value = input.nextDouble();

        System.out.println (value + " feet is " + " meters " + meters);
    }
}

我还需要添加什么才能将英尺转换为米?谢谢!

4

3 回答 3

4

您就在那里获得了转化价值,0.305. 这个数字表示多少等于 1英尺,所以要计算多少米等于value英尺数,我们只需乘以:

double meters = value * feetToMeters;
于 2013-01-08T23:41:21.010 回答
2

With your variable names, you would need:

double meters = value * feetToMeters;

于 2013-01-08T23:41:02.290 回答
1
import java.util.Scanner;

public class feetToMeters {

  public static void main (String [] args) {   
  Scanner input = new Scanner (System.in);

  System.out.println ("Enter a value for feet: ");
  double value = input.nextDouble();
  double meters = value/3.2808;
  System.out.println (value + " feet is " + meters + " meters ");

    }
}
于 2013-01-08T23:44:23.417 回答