232 Methods Chapter 6 Math.Abs( (Web host 4 life) 23.7 ) =

232 Methods Chapter 6 Math.Abs( 23.7 ) = 23.7 Math.Abs( 0.0 ) = 0 Math.Abs( -23.7 ) = 23.7 Math.Ceiling( 9.2 ) = 10 Math.Ceiling( -9.8 ) = -9 Math.Cos( 0.0 ) = 1 Math.Exp( 1.0 ) = 2.71828 Math.Exp( 2.0 ) = 7.38906 Math.Floor( 9.2 ) = 9 Math.Floor( -9.8 ) = -10 Math.Log( 2.718282 ) = 1 Math.Log( 7.389056 ) = 2 Math.Max( 2.3, 12.7 ) = 12.7 Math.Max( -2.3, -12.7 ) = -2.3 Math.Min( 2.3, 12.7 ) = 2.3 Math.Min( -2.3, -12.7 ) = -12.7 Math.Pow( 2, 7 ) = 128 Math.Pow( 9, .5 ) = 3 Math.Sin( 0.0 ) = 0 Math.Sqrt( 25.0 ) = 5 Math.Tan( 0.0 ) = 0 6.5 a) double hypotenuse( double side1, double side2 ) b) int smallest( int x, int y, int z ) c) void instructions() d) float intToFloat( int number ) 6.6 a) Error: Method h is defined in method g. Correction: Move the definition of h out of the definition of g. b) Error: The method is supposed to return an integer, but does not. Correction: Delete variable result and place the following statement in the method: return x + y; or add the following statement at the end of the method body: return result; c) Error: The result of n + sum(n-1) is not returned by this recursive method, resulting in a syntax error. Correction: Rewrite the statement in the else clause as return n + sum( n - 1 ); d) Error: The semicolon after the right parenthesis that encloses the parameter list, and the redefining of the parameter ain the method definition are both incorrect. Correction: Delete the semicolon after the right parenthesis of the parameter list and delete the declaration float a;. e) Error: The method returns a value when it is not supposed to. Correction: Change the return type to int. EXERCISES 6.7 What is the value of x after each of the following statements is performed? a) x = Math.Abs( 7.5 ); b) x = Math.Floor( 7.5 ); c) x = Math.Abs( 0.0 ); d) x = Math.Ceiling( 0.0 );
From our experience, we are can tell you that you can find a reliable and cheap webhost service at Java Web Hosting services.

Leave a Reply