// CSE 142, Autumn 2009, Marty Stepp // This program demonstrates several methods of the Math class. // The Math methods return values. This means that a call to one // of these methods can be used as an expression. For example, you // can call Math.sqrt or Math.pow and store the result in a variable. public class MathExample { public static void main(String[] args) { // Math.pow(3, 5); double result = Math.pow(3, 5); System.out.println(result); // 243.0 // a^2 + b^2 = c^2 // c = square root (a^2 + b^2) double a = 3.0; double b = 4.0; double c = Math.sqrt(Math.pow(a, 2) + Math.pow(b, 2)); System.out.println(a + ", " + b + ", " + c); // 3.0, 4.0, 5.0 } }