Page 460 - CA_Blue( J )_Class10
P. 460

25              System.out.println("Circumference of a Circle " + c);
                26              System.out.println("Perimeter of a square "+p1);

                27              System.out.println("Perimeter of a rectangle "+ p2);
                28          }

                29      }

              Output
              Circumference of a Circle 28.278

              Perimeter of a square 16
              Perimeter of a rectangle 20

                                                         Variable Description
                 NAME       DATATYPE                                     DESCRIPTION
               r               int      Radius of a circle
               s               int      Side of a square
               l               int      Length of a rectangle

               b               int      Breadth of a rectangle
               c               int      Variable to store circumference of a circle
               p1              int      Variable to store perimeter of a square
               p2              int      Variable to store perimeter of a rectangle


              (f)   Programs involving data members, member methods invoking the methods with respect to the object created.

                             class            :   Salary
                Program 6
                             Data Members     :     String n (Stores Name), double ms (Stores Monthly Salary),
                                                  double it (Stores Income Tax)
                             Methods          :
                             void accept()    :   Accepts the data n and ms
                             void cal()       :   Calculates  the  income  tax  at  5%  of  the  annual  salary  exceeding
                                                  Rs. 175000
                             void display()   :   Displays the details.

                 1      import java.util.*;
                 2      class Salary         // Declaration of class Salary

                 3      {

                 4          String n;         // Data Members
                 5          double ms, it;

                 6          void accept()         // Method to accept name and monthly salary
                 7          {

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





                458458  Touchpad Computer Applications-X
   455   456   457   458   459   460   461   462   463   464   465