I just started me java class and im confused about how powers work, such as
Volume of Cylinder = PIE (radius)2(SUPPOSED TO BE SQUARE, NOT 2) *height
how does the above translate to java code? specificly the power of 2, sry im stupid, thx:D
Printable View
I just started me java class and im confused about how powers work, such as
Volume of Cylinder = PIE (radius)2(SUPPOSED TO BE SQUARE, NOT 2) *height
how does the above translate to java code? specificly the power of 2, sry im stupid, thx:D
For exponents you use:
Take a look at the Java Platform SE 6 class. Most notably the pow method.
I always write squares out (in my mind this is faster and more accurate, but not by much) :P
Mmm, PIE. It's actually PI, and you can use Math.PI for the floating point representation of this number. Also, in Java you must explicitly spell out everywhere you're performing a multiplication/add/etc.
Code Java:double a = 3; double b = 3a; // error double b = 3 a; // error double b = 3 * a; // correct
Volume of Cylinder = PI(radius)2(power 2) * height
Surface Area of Cylinder = 2 PI radius * height
ok so im confused on why my teacher would give me the above as a formulas. at my level of math and java programming the above makes no sense.. i can decipher the top one. but 2 pi radius * height.. umm wtf
so its 2 * pi * radius * height? Why have one multiplication symbol and not the rest?
It isn't in parenthesis.. look at volume. o well, i got it fiqured out, i think my teachers kind of mean tho. THanks for the help everyone.
Did you see my above post?