forked from VimalKrishnaRao/OOP-in-Java-Lab
-
Notifications
You must be signed in to change notification settings - Fork 0
/
3EmployeeDetails.java
47 lines (39 loc) · 1.08 KB
/
3EmployeeDetails.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import java.util.Scanner;
class Employee
{
int empNo;
String name;
String phoneNumber;
public Employee(int empNo, String name, String phoneNumber)
{
this.empNo = empNo;
this.name = name;
this.phoneNumber = phoneNumber;
}
}
public class Main
{
public static void main(String args[])
{
Scanner sc = new Scanner(System.in);
Employee[] employees = new Employee[5];
for (int i = 0; i < 5; i++)
{
System.out.print("Enter employee number: ");
int empNo = sc.nextInt();
System.out.print("Enter employee name: ");
String name = sc.nextLine();
System.out.print("Enter employee phone number: ");
String phoneNumber = sc.nextLine();
employees[i] = new Employee(empNo, name, phoneNumber);
}
for (int i = 0; i < 5; i++)
{
Employee employee = employees[i];
System.out.println("Employee number: " + employee.empNo);
System.out.println("Employee name: " + employee.name);
System.out.println("Employee phone number: " + employee.phoneNumber);
System.out.println();
}
}
}