Java Blog

 
 
 
import java.util.*;
import java.io.*;

class  MenuDriven
{
    public static void main(String args[]) 
    {
         Vector itemList = new Vector();
          String str,item;
          int i,j,len,choice,pos;

           len=args.length;
          for(i=0;i<len;i++)
              itemList.addElement(args[i]);

          while(true)
          {
               System.out.println(\"\\n\\nChoose your choice ...\");
               System.out.println(\"1) Delete  Item\");
               System.out.println(\"2) Add Item at Specified Location \");
               System.out.println(\"3) Add Item at  the End of the list\");
               System.out.println(\"4) Print Vector List \");
               System.out.println(\"5) Exit\");
               System.out.print(\"Enter your choice : \");
               System.out.flush();
               try{
                   BufferedReader obj = new BufferedReader(new InputStreamReader(System.in));
                   str=obj.readLine();
                   choice=Integer.parseInt(str);
                   switch(choice)
                   {
                       case 1 :    System.out.print(\"Enter Item you want to delete : \");
                                           str=obj.readLine();
                                        itemList.removeElement(str);  //string is not needed to convert object type 

as it
                                                                                          //is already object of 

class String
                                        break;
                      case 2 :     System.out.print(\"Enter Item to be Insert : \");
                                        System.out.flush();
                                        item=obj.readLine();
                                        System.out.print(\"Enter Position to insert item : \");
                                        str=obj.readLine();
                                        pos=Integer.parseInt(str);
                                        itemList.insertElementAt(item,pos-1);
                                        break;
                      case 3 :     System.out.print(\"Enter Item to be Insert : \");
                                        System.out.flush();
                                        item=obj.readLine();
                                        itemList.addElement(item);
                                        break;
                     case 4 :      len=itemList.size();
                                        System.out.println(\"\\nItem Display \");
                                        for(i=0;i<len;i++)
                                        {
                                               System.out.println((i+1)+\") \"+itemList.elementAt(i));
                                        }
                                        break;
                      case 5 :     System.out.println(\"\\n\\nThank You for using this software.....\");
                                        System.exit(1);
                                        break;
                      default :     System.out.println(\"\\nEntered Choice is Invalid\\nTry Again\\n\");
                    }
                }
            catch(Exception e) {}
         }      
    }
}

    Related Post:
  1. Write a program for restaurant

  2. An applet program that creates string dynamically and displays it

  3. Corba program of reverse string

  4. Program to print a string on Standard Output Device

  5. CORBA PROGRAM TO GET THE HTML CODE FROM ANY URL

  6. Given a list of marks ranging form 0 to 100, write a program to compute and print the number of students marks

  7. Program to show an example of using a Static Nested Class outside the Top-Level Class

  8. Program of FTP client and server

  9. Application for counting factorial of a given number

  10. Program to show the use of If-Else Statement

  11. Program to change characters in a StringBuffer objects and to reverse its contents

  12. Program for calculating area of a circle on server side,when a client sends request along with given radius and then displaying result on client side

  13. Develop a game application in CORBA for which the player will guess a number between 1 to 100, which will be compared to the random number generated b

  14. Program to show an example of extraction of characters from a StringBuffer objects

  15. Program which calls the method sort(int []a) which throws the Exception ArithmeticException, NullPointerException, ArrayIndexOutOfBoundsException

  16. Program to show an example of Calling a Base Class Method from a Derived Class

  17. Program to show an example of modifying String objects

  18. Program to declare, initialize and print an array of integers

  19. Program to show an example of creating a String object from a StringBuffer Object

  20. Program to show insertion of StringBuffer, String objects and other Basic Data Types into a StringBuffer object