Height and Displacement (cont’d)
Now translate these equations to Java syntax: double PI = Math.PI; // for brevity d_double = b*Math.cos( PI - alpha ); h_double = b*Math.sin( PI - alpha ); // convert double values to int: d = ( int ) Math.round( d_double ); h = ( int ) Math.round( h_double );
Note: All methods and variables of the Math class are static and must be qualified