这是我的代码
import java.util.Scanner;
public class assignment4 {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.println("Enter a");
double aa = input.nextDouble();
System.out.println("Enter b");
double bb = input.nextDouble();
System.out.println("Enter c");
double cc = input.nextDouble();
double discriminant = (bb * bb - 4 * aa * cc);
discriminant = Math.power(discriminant,0.5);
}
}
我在这部分收到错误。
discriminant = Math.power(discriminant,0.5);
我可能做错了什么?这是错误btw
assignment4.java:15: error: cannot find symbol
discriminant = java.lang.Math.power(discriminant,0.5);
^
symbol: method power(double,double)
location: class Math
1 error
答案 0 :(得分:0)
您需要使用的方法是Math.pow(discriminant, 0.5)