Page 155 - CA_Blue( J )_Class9
P. 155

b.   System.out.println(Math.rint(-5.5));
                      Ans.  -6.0
                      c.   System.out.println(Math.rint(5.5));
                      Ans.  6.0
                      d.   System.out.println(Math.rint(-2.8));
                      Ans.  -3.0
                    4.   Write the output:
                      a.   System.out.println(Math.cbrt(15625));
                      Ans.  25.0
                     b.   System.out.println(Math.sqrt(81));
                      Ans.  9.0
                    5.   Write the final value that is stored in c and d:
                       double a= -10.2, b=-44.1,c,d;
                       c= Math.abs(Math.floor(a));
                       d=Math.ceil(Math.abs(b));
                   Ans.  c = 11.0
                      d = 45.0
                    6.   Convert the mathematical expression to Java expression.
                            2
                      a.    a + c 2
                      Ans.  Math.sqrt(Math.pow(a,2) + Math.pow(c,2))
                          1 n
                     b.    a
                      Ans.  Math.pow(a,1/n)

                                    2
                             −+    b −4 ac
                              b
                      c.   x =     a 2
                      Ans.  x = (-b + Math.sqrt(Math.pow(b,2) – (4 * a *c)))/(2*a)
                     d.   sin a cos b + cos a sin b where a and b are in radian
                      Ans.  Math.sin(a)*Math.cos(b) + Math.cos(a)*Math.sin(b)
                    7.  Write down Java expression for:
                                      2
                      a.   T = √(A  + B  + C ).
                                  2
                               2
                      Ans.  T = Math.sqrt(Math.pow(A,2) + Math.pow(B,2) + Math.pow(C,2));
                                2
                     b.   √(2as + u ).
                      Ans.  Math.sqrt(2 * a * s + Math.pow(u,2))
                    8.   What will the following function return when executed?
                     (i)   Math.max(-17, -19);
                     (ii)   Math.ceil(7.8);
                 Ans.  i) -17 ii) 8.0
                    9.   What are the final values stored in variables x and y below?
                       double a = -6.35;
                       double b = 14.74;
                       double x = Math.abs(a);
                       double y = Math.rint(b);
                 Ans.  x = 6.35
                      y = 15.0





                                                                                    Mathematical Library Methods   153
   150   151   152   153   154   155   156   157   158   159   160