Guest User

Untitled

a guest
May 26th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1. ID Name Salary
  2. 23 Alex 23000
  3. 24 John 24000
  4.  
  5. import java.util.Scanner;
  6. import java.util.ArrayList;
  7. import java.util.List;
  8.  
  9. public class Employee {
  10. private static int empNum;
  11. private static String empName;
  12. private static double empSal;
  13. private static Scanner sc;
  14.  
  15. public Employee(int e, String n,double s){
  16. empNum = e;
  17. empName=n;
  18. empSal = s;
  19.  
  20. }
  21.  
  22. public int getEmpNum(){
  23. return empNum;
  24. }
  25. public String getEmpName() {
  26. return empName;
  27. }
  28.  
  29. public double getSalary(){
  30. return empSal;
  31. }
  32.  
  33. public void display() {
  34.  
  35. System.out.println("ID"+" "+ "Name "+"Salary"+"n");
  36. System.out.println(empNum + empName + empSal);
  37.  
  38. }
  39. public static void main(String[]args){
  40. List<Employee> employeeList= new ArrayList<Employee>();
  41.  
  42. for(int i = 0; i < 2; i++) {
  43.  
  44. sc = new Scanner(System.in);
  45. System.out.printf("Please enter your employee number:");
  46. int e = sc.nextInt();
  47. System.out.println("Please Eneter your employee name:");
  48. String n=sc.next();
  49. System.out.printf("Please enter your salary:");
  50. double s= sc.nextDouble();
  51. employeeList.add(new Employee(e,n, s));
  52.  
  53. }
  54.  
  55. for (int j=0;j<2;j++) {
  56. Employee[] array = new Employee[2];
  57. array[j] = new Employee(empNum,empName,empSal);
  58. array[j].display();
  59. }
  60.  
  61.  
  62. }
  63.  
  64. }
Add Comment
Please, Sign In to add comment