
Write a program to store information of 10 employees and to display of an employee depending upon the employee no given by the user using structure

Hi Friend,
Try this:
import java.util.*;
class Information{
int no;
String name;
String address;
int contactNo;
Information(int no,String name,String address,int contactNo){
this.no=no;
this.name=name;
this.address=address;
this.contactNo=contactNo;
}
public int getNo(){
return no;
}
public String getName(){
return name;
}
public String getAddress(){
return address;
}
public int getContactNo(){
return contactNo;
}
}
public class EmployeeInformation{
public static void main(String[] args){
ArrayList<Information> list=new ArrayList<Information>();
Scanner input=new Scanner(System.in);
for(int i=0;i<4;i++){
System.out.println();
System.out.println("-----Employee "+(i+1)+"-----");
System.out.println("Enter empno: ");
int no=input.nextInt();
System.out.println("Enter name: ");
String name=input.next();
System.out.println("Enter address: ");
String address=input.next();
System.out.println("Enter contact no: ");
int contactno=input.nextInt();
list.add(new Information(no,name,address,contactno));
}
System.out.println(" ");
System.out.print("Enter Employee Id: ");
int id = input.nextInt();
for(Information s : list){
if(id == s.getNo())
{
System.out.print(s.getName()+" " +s.getAddress()+" "+s.getContactNo());
}
}
}
}
Thanks