import java.util.*;
public class Employee{
private String emplo [];
private int count;
private int size=10;
private String emp;
public Employee(int size){
String [] emplo=new String [10];
count=0;
}
public Employee(){
this(10);
}
public boolean isFull(){
return count== emplo.length;
}
public boolean isEmpty(){
return count==0;
}
public void add(int x){
if(isFull())
emplo[count++]=x;
else
System.out.println("\n!!!Sorry the Array is Full");
}
public String search(int x){
boolean flag=false;
for(int i=0;i<this.count;i++){
if ( x.equals(emplo[i]) ){
flag=true;
x=i;
}
if(flag==false){
x=-1;
}
return x;
}
}
public void display(){
for(int i=0;i<emplo.length;i++ )
System.out.println(emplo[i]+"");
System.out.println();
}
public static void main(String [] args){
int choice;
String num1;
String num2;
Employee e= new Employee();
Scanner s=new Scanner(System.in);
System.out.println("Welcome to this Application");
do
{
System.out.println("[1] Add Name\n[2]Search Name\n[3]Dislay Name\n[4]Exit");
System.out.println("Enter choice:");
choice= s.nextInt();
switch(choice){
case 1:System.out.println("Enter Employee name");
num2=s.nextLine();
e.add(num2);break;
case 2: if(!(e.isEmpty())){
System.out.println("\nEnter name to search:");
num1=s.nextLine();
System.out.println ( (emplo[i] + "is in "+e.search(num1)));
}
else
System.out.println("\n There are no name to search.\nAdd name first:");
break;
case 3: System.out.println("The names you entered are:");
e.display();
System.out.println();
break;
case 4: System.out.println("\nThank you");break;
default:System.out.println("\nPlease enter the choices given in the menu:");break;
}
}while(!(choice==4));
}
}
Can some one help me to solve this......I should input a name of the employee then it should return position of it in the array and it should display name been input..can someone check this its still have an error......