/** Program: EssentialExpress Class Purpose: demonstrate Java math expressions; @author john@december.com @version 1.03; 21 Nov 95 Note: converted to 1.00 beta Output: example result = 308.123 example result = 59.0567 absolute value of -3 = 3 a random number (0.0f to 1.0f) = 0.24827 round(3.65f) = 4 2 to the third power (2*2*2) = 8 maximum of 3.98f and 14.2f = 14.2 */ class EssentialExpress{ public static void main (String args[]) { double example; // double precision is available for math //math operations are available: example = (3+2) + 5*3/7 + 3.123f + (42*7 + 4); System.out.println("example result = " + example); //common math functions are available: example = Math.sin(0.50f) + Math.log(13) + Math.sqrt(2) + Math.exp(4); System.out.println("example result = " + example); //other functions: System.out.println("absolute value of -3 = " + Math.abs(-3)); System.out.println("a random number (0.0f to 1.0f) = " + Math.random()); System.out.println("round(3.65f) = " + Math.round(3.65f)); System.out.println("2 to the third power (2*2*2) = " + Math.pow(2, 3)); System.out.println("maximum of 3.98f and 14.2f = " + Math.max(3.98f, 14.2f)); } }