7 - 2 + Math.log10(1000) + Math.log(Math.pow(Math.E, 5))
这与Java中的相同是什么我不能插入它,因为如果我在类/方法中编译它,即使它检查好也会给我错误。我不确定我做错了什么,因为我得到了10.171和更多数字,但它仍然说我在网上的错误 - 我的做法 - 它。我知道7 - 2 + Math.log10(1000)最终等于8但我只是搞砸了添加的最后一部分原因我并不完全确定当Math.E为5的幂时的值和日志
答案 0 :(得分:2)
这跑了并输出了13
public class MathTest{
public static void main(String[] args){
System.out.print( 7 - 2 + Math.log10(1000) + Math.log(Math.pow(Math.E, 5)) );
}
}
答案 1 :(得分:1)
final
部分不问题:
public class MathCode {
public static final double x1 = 7 - 2 + Math.log10(1000)
+ Math.log(Math.pow(Math.E, 5));
public static double x2 = 7 - 2 + Math.log10(1000)
+ Math.log(Math.pow(Math.E, 5));
private static double x3 = 7 - 2 + Math.log10(1000)
+ Math.log(Math.pow(Math.E, 5));
private final double x4 = 7 - 2 + Math.log10(1000)
+ Math.log(Math.pow(Math.E, 5));
public final double x5 = 7 - 2 + Math.log10(1000)
+ Math.log(Math.pow(Math.E, 5));
private double x6 = 7 - 2 + Math.log10(1000)
+ Math.log(Math.pow(Math.E, 5));
public double x7 = 7 - 2 + Math.log10(1000) + Math.log(Math.pow(Math.E, 5));
public static void main(String... args) {
final MathCode mathCode = new MathCode();
final double x8 = 7 - 2 + Math.log10(1000)
+ Math.log(Math.pow(Math.E, 5));
double x9 = 7 - 2 + Math.log10(1000) + Math.log(Math.pow(Math.E, 5));
System.out.println("x1: " + x1);
System.out.println("x2: " + x2);
System.out.println("x3: " + x3);
System.out.println("x4: " + mathCode.x4);
System.out.println("x5: " + mathCode.x5);
System.out.println("x6: " + mathCode.x6);
System.out.println("x7: " + mathCode.x7);
System.out.println("x8: " + x8);
System.out.println("x9: " + x9);
}
}
以下结果是:
x1: 13.0
x2: 13.0
x3: 13.0
x4: 13.0
x5: 13.0
x6: 13.0
x7: 13.0
x8: 13.0
x9: 13.0
答案 2 :(得分:1)
尝试使用Math.exp(5)
代替Math.pow(Math.E,5)