// purpose: demonstrate some math calculations import java.util.*; public class ComputeIt { // method main(): program starting point public static void main( String[] args ) { // set up input scanner Scanner keyboard = new Scanner( System.in ); // get the value of interest System.out.print( "Enter two decimal values: " ); double x = keyboard.nextDouble(); double y = keyboard.nextDouble(); System.out.println(); double d1 = Math.sqrt( x ); double d2 = Math.abs( y ); double d3 = Math.max( x, y ); double d4 = Math.pow( x, y ); double d5 = Math.rint( x ); double d6 = Math.rint( y ); int i1 = (int) ( x ); int i2 = (int) ( y ); System.out.println(); System.out.println( "Values" ); System.out.println( " x = " + x ); System.out.println( " y = " + y ); System.out.println(); System.out.println( "Calculations" ); System.out.println( " Math.sqrt( x ) = " + d1 ); System.out.println( " Math.abs( y ) = " + d2 ); System.out.println( " Math.max( x, y ) = " + d3 ); System.out.println( " Math.pow( x, y ) = " + d4 ); System.out.println( " Math.rint( x ) = " + d5 ); System.out.println( " Math.rint( y ) = " + d6 ); System.out.println(); System.out.println( " (int)( x ) = " + i1 ); System.out.println( " (int)( y ) = " + i2 ); } }