在Java公式中使用电子元素

huangapple go评论76阅读模式
英文:

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。以下是一个例子:

public static void main(String[] args) 
{
    double a = 2.0;
    System.out.println(Math.exp(a));
}
//输出结果 = 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

`
public static void main(String[] args) 
{
    double a = 2.0;
    System.out.println(Math.exp(a));
}
//output = 7.38905609893065
`

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

答案2

得分: 0

你可以使用Math.exp()

示例:

import java.lang.Math;

// 在主函数内部
Math.exp(1.0);        // e^1
Math.exp(1.6);        // e^1.6
英文:

You could use Math.exp().

Example:

import java.lang.Math;

// inside main
Math.exp(1.0);        // e^1
Math.exp(1.6);        // e^1.6

答案3

得分: -1

import java.lang.Math;

class Answer {

    // 驱动代码
    public static void main(String args[])
    {
        double a = 30;
        double b = 2;
        System.out.println(Math.pow(a, b));

        a = 3;
        b = 4;
        System.out.println(Math.pow(a, b));

        a = 2;
        b = 6;
        System.out.println(Math.pow(a, b));
    }

    // 你可以使用 Math.pow(e, x);
}
英文:
import java.lang.Math; 
  
class Answer { 
  
    // driver code 
    public static void main(String args[]) 
    { 
        double a = 30; 
        double b = 2; 
        System.out.println(Math.pow(a, b)); 
  
        a = 3; 
        b = 4; 
        System.out.println(Math.pow(a, b)); 
  
        a = 2; 
        b = 6; 
        System.out.println(Math.pow(a, b)); 
    } 

//you can use Math.pow(e,x);

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

发表评论

匿名网友

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

确定