Hi I'm in my 2nd week of Java and I was assigned a mah worksheet formula, but I don't know how to do it and I really need help. The question is: Write a formula, which will add 5 the the cube of double t times double n and assign it to double X.
what I have so far
X= Math.cube(t*n)+5;
I feel like I did his wrong since I hardly understand how to do it.
... add 5 to the cube of double t times double n and assign it to double X.
It's ambiguous in that it doesn't really specify whether it's:
(the cube of t) times (n)
; orthe cube of (t times n)
1.So you'll be stuck with one of:
X = Math.pow(t,3) * n + 5
X = Math.pow(t*n,3) + 5
I haven't looked deeply at the changes in Java 8 by the way but I'm pretty certain there's no Math.cube()
in older iterations at least. Hence the use of Math.pow()
.
1 This is why computer languages are far superior to natural ones. If only my wife and kids spoke C, I'd be a happy man :-)