
The pow Method
Example 3.14 demonstrates how some of these Math methods can be used
in a Java program.
1 /* A demonstration of some Math class methods
2 Anderson, Franceschi
3 */
4
5 public class MathMethods
6 {
7 public static void main( String [ ] args )
8 {
9 double d2 = Math.log( 5 );
10 System.out.println( “\nThe log of 5 is “ + d2 );
11
12 double d4 = Math.sqrt( 9 );
13 System.out.println( “\nThe square root of 9 is “ + d4 );
14
15 double fourCubed = Math.pow( 4, 3 );
16 System.out.println( “\n4 to the power 3 is “ + fourCubed );
17
18 double bigNumber = Math.pow( 43.5, 3.4 );
19 System.out.println( “\n43.5 to the power 3.4 is “ + bigNumber );
20 }
21 ...