An open API service indexing awesome lists of open source software.

https://github.com/imsaiful/shilpa


https://github.com/imsaiful/shilpa

Last synced: 8 months ago
JSON representation

Awesome Lists containing this project

README

          

# shilpa
Menu driven for the TreeSet
```
import java.util.*;
class Shilpa
{
public static void main(String[] args)
{
Scanner in=new Scanner(System.in);
TreeSet ts = new TreeSet();
System.out.println("Enter the initial Capacity of TreeSet");
int n=in.nextInt();
for(int i=1;i<=n;i++)
{
System.out.println("Enter the "+i+" element ");
int x=in.nextInt();
ts.add(x);

}
boolean condition=true;
while(condition)
{
System.out.println("Enter your choise");
System.out.println("1. View Elements \n2. Insert Element\n3. Delete Elements\n4. Search Element\n5. Exit");
int c=in.nextInt();
if(c==1)
{
Iterator itr=ts.iterator();
while(itr.hasNext()){
System.out.print(itr.next()+" ");
}
}
else if(c==2)
{
System.out.println("Enter the element");
int x=in.nextInt();
ts.add(x);
System.out.println("Element is inserted Successfully");
}
else if(c==3)
{
System.out.println("Enter the element to delete");
int x=in.nextInt();
if(ts.remove(x))
{
System.out.println("Element deleted");
}
else
{
System.out.println("Element not exist");
}

}
else if(c==4)
{
System.out.println("Enter the element to search");
int x=in.nextInt();
int y=ts.headSet(x).size()+1;
if(y<=ts.size())
{
System.out.println("Elements found at position "+y);
}
else
{
System.out.println("Elements not found");
}

}
else if(c==5)
{
System.exit(0);

}
else
{
System.out.println("Please enter the correct option");
}

}


}
}

```