Page 152 - CA_Blue( J )_Class9
P. 152

Program 6      Write a program to demonstrate the use of Math.sqrt() method.

                     1     class square_root

                     2     {
                     3         public static void main(String[] args)

                     4         {
                     5             System.out.println("sqrt(49)= " + Math.sqrt(49));

                     6         }
                     7     }

                  You will get the following output:
















                   Program 7      Write a program to demonstrate the use of Math.ceil() method.

                     1     public class MathCeil
                     2     {

                     3         public static void main(String args[])
                     4         {

                     5         System.out.println("ceil(35.3)= " + Math.ceil(35.3));
                     6         System.out.println("ceil(-59.2)= " + Math.ceil(-59.2));

                     7         System.out.println("ceil(0.8)= " + Math.ceil(0.8));
                     8         System.out.println("ceil(-0.2)= "+ Math.ceil(-0.2));

                     9         }
                    10     }

                  You will get the following output:


















                   150    Touchpad Computer Applications-IX
   147   148   149   150   151   152   153   154   155   156   157