First Step:
Employee.java
package EmployeePayroll;
public class Employee
{
public int[] Emp_id;
public String[] Emp_Name;
public int[] getEmpId()
{
return Emp_id;
}
public void setEmpId(int[] empId)
{
Emp_id = empId;
}
public String[] getEmp_Name() {
return Emp_Name;
}
public void setEmp_Name(String[] emp_Name) {
Emp_Name = emp_Name;
}
}
---------------------------------------------------------------------------------------------------------------------------
After Then:
Executable.java
package EmployeePayroll;
import java.util.Scanner;
public class Executable {
private static Scanner input;
public static void main(String args[])
{
input = new Scanner(System.in);
System.out.print("eNTER ID");
Employee e=new Employee();
int Emp_id[]=new int[10];
String Emp_Name[]=new String[10];
for (int i = 0; i <10; i++){
Emp_id[i] = input.nextInt();
Emp_Name[i]=input.next();
e.setEmpId(Emp_id);
e.setEmp_Name(Emp_Name);
}
for (int i = 0; i <10; i++){
System.out.println(e.getEmpId()[i]+"and "+e.getEmp_Name()[i]);
}
}
}
Intput Command Line:
ENTER ID
1
arpit
2
dshdk
3
dskdh
4
fdfd
5
fdfd
6
dfdf
7
dfd
8
dfd
9
fdf
10
fdf
Output:
1and arpit
2and dshdk
3and dskdh
4and fdfd
5and fdfd
6and dfdf
7and dfd
8and dfd
9and fdf
10and fdf
Employee.java
package EmployeePayroll;
public class Employee
{
public int[] Emp_id;
public String[] Emp_Name;
public int[] getEmpId()
{
return Emp_id;
}
public void setEmpId(int[] empId)
{
Emp_id = empId;
}
public String[] getEmp_Name() {
return Emp_Name;
}
public void setEmp_Name(String[] emp_Name) {
Emp_Name = emp_Name;
}
}
---------------------------------------------------------------------------------------------------------------------------
After Then:
Executable.java
package EmployeePayroll;
import java.util.Scanner;
public class Executable {
private static Scanner input;
public static void main(String args[])
{
input = new Scanner(System.in);
System.out.print("eNTER ID");
Employee e=new Employee();
int Emp_id[]=new int[10];
String Emp_Name[]=new String[10];
for (int i = 0; i <10; i++){
Emp_id[i] = input.nextInt();
Emp_Name[i]=input.next();
e.setEmpId(Emp_id);
e.setEmp_Name(Emp_Name);
}
for (int i = 0; i <10; i++){
System.out.println(e.getEmpId()[i]+"and "+e.getEmp_Name()[i]);
}
}
}
Intput Command Line:
ENTER ID
1
arpit
2
dshdk
3
dskdh
4
fdfd
5
fdfd
6
dfdf
7
dfd
8
dfd
9
fdf
10
fdf
Output:
1and arpit
2and dshdk
3and dskdh
4and fdfd
5and fdfd
6and dfdf
7and dfd
8and dfd
9and fdf
10and fdf
No comments:
Post a Comment