在Java公式中使用电子元素

huangapple 未分类评论49阅读模式
英文:

Using electron in a formula in java

问题

I'm trying to write a Java program that can take values and put them into a formula involving electrons. How can I calculate e^x in Java?

英文:

I'm trying to write a Java program that can take values and put them into a formula involving electron. How can I calculate e^x in Java?

答案1

得分: 1

你可以使用java.lang.Math.exp()方法来计算e^x。以下是一个例子:

  1. public static void main(String[] args)
  2. {
  3. double a = 2.0;
  4. System.out.println(Math.exp(a));
  5. }
  6. //输出结果 = 7.38905609893065

你可以通过以下链接了解更多信息:https://www.javatpoint.com/java-math-exp-method

英文:

you can use java.lang.Math.exp() method to calculate e^x.
here is an example

  1. `
  2. public static void main(String[] args)
  3. {
  4. double a = 2.0;
  5. System.out.println(Math.exp(a));
  6. }
  7. //output = 7.38905609893065
  8. `

you can read more about this using this link.
https://www.javatpoint.com/java-math-exp-method

答案2

得分: 0

你可以使用Math.exp()

示例:

  1. import java.lang.Math;
  2. // 在主函数内部
  3. Math.exp(1.0); // e^1
  4. Math.exp(1.6); // e^1.6
英文:

You could use Math.exp().

Example:

  1. import java.lang.Math;
  2. // inside main
  3. Math.exp(1.0); // e^1
  4. Math.exp(1.6); // e^1.6

答案3

得分: -1

  1. import java.lang.Math;
  2. class Answer {
  3. // 驱动代码
  4. public static void main(String args[])
  5. {
  6. double a = 30;
  7. double b = 2;
  8. System.out.println(Math.pow(a, b));
  9. a = 3;
  10. b = 4;
  11. System.out.println(Math.pow(a, b));
  12. a = 2;
  13. b = 6;
  14. System.out.println(Math.pow(a, b));
  15. }
  16. // 你可以使用 Math.pow(e, x);
  17. }
英文:
  1. import java.lang.Math;
  2. class Answer {
  3. // driver code
  4. public static void main(String args[])
  5. {
  6. double a = 30;
  7. double b = 2;
  8. System.out.println(Math.pow(a, b));
  9. a = 3;
  10. b = 4;
  11. System.out.println(Math.pow(a, b));
  12. a = 2;
  13. b = 6;
  14. System.out.println(Math.pow(a, b));
  15. }
  16. //you can use Math.pow(e,x);

huangapple
  • 本文由 发表于 2020年5月5日 21:03:02
  • 转载请务必保留本文链接:https://java.coder-hub.com/61613837.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定