如何将脚转换成米?

时间:2013-01-08 23:38:28

标签: java

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);
    }
}

我还需要添加什么来将脚转换为米?谢谢!

3 个答案:

答案 0 :(得分:4)

您的转化价值为0.305。这个数字表示有多少等于1 英尺,所以要弄清楚有多少米等于value英尺,我们只需乘以:

double meters = value * feetToMeters;

答案 1 :(得分:2)

使用变量名称,您需要:

double meters = value * feetToMeters;

答案 2 :(得分: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 ");

    }
}