Page 477 - CA_Blue( J )_Class10
P. 477

14             System.out.println("Math.abs(-4.4)       : " + Math.abs(-4.4));
                  15             System.out.println("Math.log(1)          : " + Math.log(1));

                  16             System.out.println("Math.round(3.4)      : " + Math.round(3.4));
                  17             System.out.println("Math.rint(2.5)       : " + Math.rint(2.5));

                  18             System.out.println("Math.random()        : " + Math.random());
                  19          }                 //Close of main()

                  20      }                 //Close of class

                 Output
                 ----Mathematical Functions ----

                 Math.min(3.4,5.8)   : 3.4
                 Math.max(3.4,5.8)  : 5.8
                 Math.sqrt(4.0)     : 2.0

                 Math.cbrt(-27.0)   : -3.0
                 Math.pow(3,2)      : 9.0
                 Math.ceil(3.4)     : 4.0

                 Math.floor(-5.8)   : -6.0
                 Math.exp(2)        : 7.38905609893065
                 Math.abs(-4.4)     : 4.4

                 Math.log(1)        : 0.0
                 Math.round(3.4)    : 3

                 Math.rint(2.5)     : 2.0
                 Math.random()      : 0.915551851684451

                 (b)  Programs to check whether a given character is an uppercase/ lowercase / digit etc.

                               Write a program to input a sentence and print the following:
                  Program 17
                               Sample Input:  The number of the car is WB2A 1356.
                               Sample output:
                               The Uppercase letters are T W B A and total number : 4
                               The Lowercase letters are h w n u m b e r o f t h e c a r i s and total number : 18
                               The digits are 2 1 3 5 6 and total number : 5


                   1      import java.util.*;           //importing package "util"

                   2      class countandprint           //declaration of class
                   3      {

                   4          public static void main()
                   5          {

                   6              Scanner sc = new Scanner(System.in);


                                                                                                                       475
                                                                                                   Internal Assessment  475
   472   473   474   475   476   477   478   479   480   481   482