0% found this document useful (0 votes)
6 views

EXp 8 Print

Uploaded by

mr.suyogbadb
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

EXp 8 Print

Uploaded by

mr.suyogbadb
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

import java.io.

*;

import java.util.*;

class Test3{

public static void main(String args[])

int ch=0,op;

Vector v=new Vector();

for(int i=0;i<args.length;i++)

v.addElement(args[i]);

BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

System.out.println("shopping list");

do

{ System.out.println("select 1-insert,2-delete,3-print");

System.out.println("enter option");

try

{ op=Integer.parseInt(br.readLine());

switch(op)

case 1:

String item;

int pos;

System.out.println("enter item to be added and position");

item=br.readLine();

pos=Integer.parseInt(br.readLine());

v.insertElementAt(item,pos);

break;

case 2:

System.out.println("enter item to be deleted");

item=br.readLine();
v.removeElement(item);

break;

case 3:

System.out.println("contents are:"+v);

break;

default:

System.exit(0);

System.out.println("you want to continue");

ch=Integer.parseInt(br.readLine());

catch(IOException e)

}}

while(ch==1);

}}

OUTPUT:-

X:\A3_52>javac -Xlint Test3.java

X:\A3_52>java Test3

SHOPPING LIST

select 1-insert,2-delete,3-print

Enter Option

Enter item to be added and possition

pen

You want to continue

select 1-insert,2-delete,3-print

Enter Option

1
Enter item to be added and possition

pencil

You want to continue

select 1-insert,2-delete,3-print

Enter Option

Enter item to be deleted

pen

You want to continue

select 1-insert,2-delete,3-print

Enter Option

content are[pencil]

You want to continue

You might also like