Page 616 - Computer science 868 Class 12
P. 616

43          }
                44        }

                45
                46       Codes for main class d3point_main
                47       import java.util.*;

                48       class d3pointMain

                49       {
                50       public static void main(String args[])
                51       {

                52       d3pointob = new d3point(10,20,30);
                53       d3point ob1 = new d3point(40,50,60);

                54           System.out.println("The distance between 2 points in plane is "+
                            ob.distance2d(ob1) +" and the space is" + ob.distance3d(ob1));
                55          }

                56       }

              Output of the preceding program is as follows:
              The distance between 2 points in plane is 42.42640687119285 and the space is 51.96152422706632


              DATA STRUCTURE


                Program 19     Stack
                               A class Stack is created to display implementation of stack.
                               Data Members
                               int s[]                      :  An array of integer type
                               int top                      :  variable holding the top position of the array
                               int size                     :  variable to store array size
                               Member Functions
                               Stack(int)                   :  A constructor to initialise data members
                               void pushitem(int)           :  To push elements into the array
                               int popitem()                :  To pop out elements of the array
                               void printstack()            :  To display the array


                 1       import java.util.*;
                 2       class Stack

                 3       {
                 4       int s[] , size,top;

                 5       Stack(int i)
                 6       {





                614614  Touchpad Computer Science-XII
   611   612   613   614   615   616   617   618   619   620   621