Wednesday 27 June 2012

java program in which we create array of object to desribes emplyee information.

import java.io.*;
class Emp
{
    int id[];
    String name[];
    int bs[];
    Emp(int id[],String name[],int bs[])
    {
        this.id=id;
        this.name=name;
        this.bs=bs;
    }



    display()
    {   
        for (int i=0;i<3;i++)
        {
        int da,hr,grs;
        System.out.println(id+name);
        da=(bs[i]*10)/100;
        hr=(bs[i]*15)/100;
        grs=da+hr+bs[i];
        System.out.println("Id is: "+Id[i] +" , name is :"+name[i]);
        System.out.println("grs"+grs);
        }
    }
}
class  EmpSalary
{
    public static void main(String args[])
    {   
        int id[]={1,2,3};
        int salary[]={20000,30000,40000};
        String name[]={"abc","cde","efg"};
       
        Emp e[]=new Emp[3];
        //above we create an array of object
        for(int i=0;i<3;i++)
        {
        //here memory allocation performed
        e[i]=new Emp(id[i],salary[i],name[i]);
        }           
    }
}

       
       

No comments:

Post a Comment