Web host music - 182 Methods Chapter 6 Method Description Example Abs(
Thursday, July 19th, 2007182 Methods Chapter 6 Method Description Example Abs( x ) absolute value of x Abs( 23.7 )is 23.7 Abs( 0 )is 0 Abs( -23.7 )is 23.7 Ceiling( x ) rounds x to the smallest integer Ceiling( 9.2 ) is 10.0 not less than x Ceiling( -9.8 )is -9.0 Cos( x ) trigonometric cosine of x Cos( 0.0 ) is 1.0 (x in radians) Exp( x ) exponential method ex Exp( 1.0 ) is approximately 2.7182818284590451 Exp( 2.0 ) is approximately 7.3890560989306504 Floor( x ) rounds x to the largest integer Floor( 9.2 )is 9.0 not greater than x Floor( -9.8 )is -10.0 Log( x ) natural logarithm of x (base e) Log( 2.7182818284590451 ) is approximately 1.0 Log( 7.3890560989306504 ) is approximately 2.0 Max( x, y ) larger value of x and y Max( 2.3, 12.7 )is 12.7 (also has versions for float, Max( -2.3, -12.7 )is -2.3 intand long values) Min( x, y ) smaller value of x and y Min( 2.3, 12.7 )is 2.3 (also has versions for float, Min( -2.3, -12.7 )is -12.7 intand long values) Pow( x, y ) x raised to power y (xy) Pow( 2.0, 7.0 )is 128.0 Pow( 9.0, .5 ) is 3.0 Sin( x ) trigonometric sine of x Sin( 0.0 ) is 0.0 (x in radians) Sqrt( x ) square root of x Sqrt( 900.0 )is 30.0 Sqrt( 9.0 )is 3.0 Tan( x ) trigonometric tangent of x Tan( 0.0 ) is 0.0 (x in radians) Fig. 6.2 Commonly used Math class methods. There are several motivations for modularizing a program with methods. The divideand- conquer approach makes program development more manageable. Another motivation is software reusability using existing methods (and classes) as building blocks to create new programs. With proper method naming and definition, we can create programs from standardized methods, rather than building customized code. For example, we did not have to define how to convert strings to integers The .NET Framework Class Library already defines such methods for us (Int32.Parse). A third motivation is to avoid repeating code in a program. Packaging code as a method allows that code to be executed from several locations in a program we simply have to call that method.
Visit our web design programs services for an affordable and reliable webhost to suit all your needs.