Page 86 - CA_Blue( J )_Class9
P. 86

Explanation of code: In each line, we are using different types of operators and related operands.
                  In the 1st line:

                         “=” acts as an assignment operator and “m”, “n”, 34.76 and 3.6 are variables and constants.
                  Similarly in the 2nd line:

                         “=” acts as an assignment operator and “a”, “b”, 1 and 4 are variables and constants.
                  In the 3rd line:
                         “=” and “*” acts as an assignment operator and binary operator respectively and “m”, “n” and “r” are
                         operands.

                  In the 4th line:
                         “=” and “-” acts as an assignment operator and binary operator respectively and “a”, “b” and “c” are
                         operands.
                  In the above example, m*n and b-a are Arithmetic Expression and r = m*n and c = b-a is said to be Arithmetic
                  Statement.
                  Arithmetic Expression: Any meaningful expression containing identifiers, literals, and arithmetical operators and
                  producing a result is called an Arithmetic Expression.
                  Example: a*b, 2*(l + b)

                  Arithmetic Statement:  When the expression is assigned to a variable, then it is called Arithmetic Statement.
                  Example: c=a*b, p=2*(l + b)

                                            Mathematical Expression       Java Expression

                                                  a+bc               a+b*c
                                                  a +b 2             a*a+b*b
                                                   2
                                                    prt
                                                   100               (p*r*t)/100.0
                                                     1
                                                  ut+ at 2           (u*t) + (1.0/2.0*a*t*t)
                                                     2

                                                   ad + bc
                                                     bd              (a*d+b*c)/(b*d)
                                                  2πr 2              2*22.0/7.0*r*r
                                                  ab+bc+ca           a*b+b*c+c*a
                                                  (m+n)(n+k)         (m+n)*(n+k)




                   Program 1      Write a program to display the use of operators.

                     1  import java.util.*;
                     2  class operators

                     3  {
                     4      public static void main()

                     5      {


                    84    Touchpad Computer Applications-IX
   81   82   83   84   85   86   87   88   89   90   91