WHAT'S NEW?
Loading...

Object array Program


import java.util.*;

class emp
{
	 int emp_id;
	 String name;
	 float salary;
	 Scanner din=new Scanner(System.in);

	 void get()
	 {
	 	System.out.println("Enter your id:");
	 	emp_id=din.nextInt();
	 	System.out.println("Enter your name:");
	 	name=din.next();
	 	System.out.println("Enter your salary:");
	 	salary=din.nextFloat();
	 }
	 void disp()
	 {
	 	 System.out.println("Name:"+name);
	 	 System.out.println("Emp_id:"+emp_id);
	 	 System.out.println("Salary:"+salary);
	 }

	 public static void main(String args[])
	 {
	 	 emp e[];
	 	 int i;
	 	 e=new emp[5];
	 	 for(i=0;i<5;i++)
	 	 {
	 	 	e[i]=new emp();
	 	 	e[i].get();
	 	 }
	 	 for(i=0;i<5;i++)
	 	 	e[i].disp();

	 }
}
Post a Comment