Page 618 - Computer science 868 Class 12
P. 618

41       for(int i=0;i<=top;i++)
                42       {

                43       if(s[i]!=0)
                44       System.out.print(s[i]+"|");

                45       }
                46       System.out.println();

                47          }
                48       }


              Codes for Class Stack_main


                 1       import java.util.*;
                 2       class Stack_Main

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

                 5       {
                 6       Scanner sc = new Scanner(System.in);
                 7       System.out.print("Stack size:");

                 8       int s= sc.nextInt();

                 9       String x;
                10       stackob = new stack(s);
                11       do

                12       {
                13       System.out.println("MAin Menu");

                14       System.out.println("Press 1 to Push item To Stack");
                15       System.out.println("Press 2 to Pop item Out of Stack");

                16       System.out.println("Press 3 to Display items of Stack");
                17       System.out.print("Enter choice");

                18       intch = sc.nextInt();
                19       switch(ch)

                20       {
                21       case 1:

                22       System.out.print("Enter a Number to Push");
                23       int n = sc.nextInt();

                24       ob.pushitem(n);




                616616  Touchpad Computer Science-XII
   613   614   615   616   617   618   619   620   621   622   623