0% found this document useful (0 votes)
644 views

Employee Details JAVA PROGRAM

This document contains code for an employee record program in Java. The program defines an Employee class with fields to store an employee's ID, name, age, department, and salary. It includes get() and disp() methods - get() prompts the user to input employee details, and disp() displays the stored employee details in a formatted table. The main() method creates an array of 5 Employee objects, calls get() to input details for each, and then calls disp() to output the employee records table.

Uploaded by

sarathroshan
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
644 views

Employee Details JAVA PROGRAM

This document contains code for an employee record program in Java. The program defines an Employee class with fields to store an employee's ID, name, age, department, and salary. It includes get() and disp() methods - get() prompts the user to input employee details, and disp() displays the stored employee details in a formatted table. The main() method creates an array of 5 Employee objects, calls get() to input details for each, and then calls disp() to output the employee records table.

Uploaded by

sarathroshan
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

.Employee Details-Practical pgm-2 /*Employee Program*/ import java.io.

*; class Employee { int id,age,salary; String name,dept; DataInputStream ob=new DataInputStream(System.in); void get()throws IOException { System.out.println("Enter the Employee no:"); id=Integer.parseInt(ob.readLine()); System.out.println("Enter the Employee name:"); name=ob.readLine(); System.out.println("Enter the Employee Age:"); age=Integer.parseInt(ob.readLine()); System.out.println("Enter the Employee Department Name:"); dept=ob.readLine(); System.out.println("Enter the Employee Basic Salary:"); salary=Integer.parseInt(ob.readLine()); } void disp()throws IOException { System.out.println(id+" "+"\t"+name+" "+"\t\t"+age+" "+"\t\t"+dept+" "+"\t\t"+salary); /*System.out.println("Staff Id:"+id);System.out.println("Staff Name:"+name); System.out.println("Staff age:"+age);System.out.println("Staff sex:"+sex); System.out.println("Staff Department"+dept);System.out.println("Staff Salary:"+salary);*/ } } class pract2 { public static void main(String aa[])throws IOException { Employee obj[]=new Employee[5]; int i; for(i=0;i<5;i++) { obj[i]=new Employee(); obj[i].get(); } System.out.println("\t\t\t"+"Employee Details"+"\t\t"); System.out.println("Empno"+"\t"+"Emp name"+"\t"+"Emp Age"+"\t"+"Emp dept"+"\t"+"Emp salary"); for(i=0;i<5;i++) { obj[i].disp();

} } }

You might also like