Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ID Name Salary
- 23 Alex 23000
- 24 John 24000
- import java.util.Scanner;
- import java.util.ArrayList;
- import java.util.List;
- public class Employee {
- private static int empNum;
- private static String empName;
- private static double empSal;
- private static Scanner sc;
- public Employee(int e, String n,double s){
- empNum = e;
- empName=n;
- empSal = s;
- }
- public int getEmpNum(){
- return empNum;
- }
- public String getEmpName() {
- return empName;
- }
- public double getSalary(){
- return empSal;
- }
- public void display() {
- System.out.println("ID"+" "+ "Name "+"Salary"+"n");
- System.out.println(empNum + empName + empSal);
- }
- public static void main(String[]args){
- List<Employee> employeeList= new ArrayList<Employee>();
- for(int i = 0; i < 2; i++) {
- sc = new Scanner(System.in);
- System.out.printf("Please enter your employee number:");
- int e = sc.nextInt();
- System.out.println("Please Eneter your employee name:");
- String n=sc.next();
- System.out.printf("Please enter your salary:");
- double s= sc.nextDouble();
- employeeList.add(new Employee(e,n, s));
- }
- for (int j=0;j<2;j++) {
- Employee[] array = new Employee[2];
- array[j] = new Employee(empNum,empName,empSal);
- array[j].display();
- }
- }
- }
Add Comment
Please, Sign In to add comment