需要帮助为此作业编写 Java 数学公式

Need help to write a Java math formula for this assignment

嗨,我在 Java 的第二周,我被分配了一个 mah 工作表公式,但我不知道该怎么做,我真的需要帮助。 问题是:写一个公式,将 double t 乘以 double n 的立方数加 5 并赋值给 double X。

到目前为止我有什么

X= Math.cube(t*n)+5;

我觉得我做错了他的事,因为我几乎不知道该怎么做。

... add 5 to the cube of double t times double n and assign it to double X.

它是模棱两可的,因为它并没有真正说明它是否是:

  • (the cube of t) times (n);或
  • the cube of (t times n)1.

所以你会被其中之一困住:

X = Math.pow(t,3) * n + 5
X = Math.pow(t*n,3) + 5

顺便说一句,我没有深入研究 Java 8 中的变化,但我很确定至少在较旧的迭代中没有 Math.cube()。因此使用 Math.pow().


1 这就是计算机语言远优于自然语言的原因。如果只有我的妻子和孩子说 C,我会是一个快乐的人:-)