如何输入浮点数

时间:2017-03-26 07:57:45

标签: java input

  public static void main(String[] args)
  {

 Scanner input = new Scanner(System.in);



  System.out.println("Enter a floating point number");

  float nA= java.util.Scanner.nextFloat();
  double nB= Math.pow(a, 3.5);

System.out.println("nB = nA^3.5" +nB);

  }
}

在这个代码我试图允许输入浮点数nA但我不知道如何

1 个答案:

答案 0 :(得分:0)

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



        System.out.println("Enter a floating point number");

        float nA= input.nextFloat();
        double nB= Math.pow(nA, 3.5);

        System.out.println("nB = nA^3.5" +nB);


    }