.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Code Snippets >> OOPS >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

java program using vector class to manipulate shop details.

Posted By:laptop charles       Posted Date: June 30, 2010    Points: 10    Category: OOPS    URL: http://www.dotnetspark.com  

To manipulate shop details
 

Using vector class to  manipulate shop details.
It contain a record to add, insert,display and delete.
import java.io.*;
import java.lang.*;
import java.util.*;
class shopping
{
public static void main(String arg[])throws IOException
{
String s;
String a[]=new String[10];
Vector v=new Vector();
int i,j,n;
do
{
System.out.println("\n Menu");
System.out.println("1.add");
System.out.println("2.delete");
System.out.println("3.insert");
System.out.println("4.display");
System.out.println("5.exit");
System.out.println("Enter your choice");
BufferedReader mr=new BufferedReader(new InputStreamReader(System.in));
j=Integer.parseInt(mr.readLine());
switch(j)
{
case 1:
System.out.println("Enter the item to be added");
s=mr.readLine();
v.addElement(s);
break;
case 2:
System.out.println("Enter the to be deleted");
n=Integer.parseInt(mr.readLine());
v.removeElementAt(n);
break;
case 3:
System.out.println("Enter the item to be inserted");
s=mr.readLine();
System.out.println("Enter the choice index");
n=Integer.parseInt(mr.readLine());
v.insertElementAt(s,n);
break;
case 4:
System.out.println(v);
break;
case 5:
break; 
}
}
while(j!=3);
}
}

     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend