-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathemployeein.java
More file actions
80 lines (74 loc) · 1.62 KB
/
Copy pathemployeein.java
File metadata and controls
80 lines (74 loc) · 1.62 KB
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import java.util.Scanner;
public class employeein {
public static void main(String[] args)
{
Officer officer=new Officer();
officer.getDetails();
officer.setSpecialization();
System.out.println("Details of Officer:");
officer.printDetails();
officer.printSpecialization();
Manager manager=new Manager();
manager.getDetails();
manager.setDepartment();
System.out.println("Details of Manager:");
manager.printDetails();
manager.printDepartment();
}
}
class Employee
{
String name;
int age;
int phoneno;
String address;
int salary;
Scanner sc=new Scanner(System.in);
public void getDetails()
{
System.out.println("Enter Name:");
name=sc.next();
System.out.println("Enter Age:");
age=sc.nextInt();
System.out.println("Enter PhoneNo:");
phoneno=sc.nextInt();
System.out.println("Enter Address:");
address=sc.next();
System.out.println("Enter Salary:");
salary=sc.nextInt();
}
public void printDetails()
{
System.out.println("Name:"+name);
System.out.println("Age:"+age);
System.out.println("Phoneno:"+phoneno);
System.out.println("Address:"+address);
System.out.println("Salary:"+salary);
}
}
class Officer extends Employee
{
String specialization;
public void setSpecialization()
{
System.out.println("Enter Specialization:");
specialization=sc.next();
}
public void printSpecialization()
{
System.out.println("Specialization:"+specialization);
}
}
class Manager extends Employee
{
String department;
public void setDepartment()
{
System.out.println("Enter Department:");
department=sc.next();
}
public void printDepartment()
{
System.out.println("Department:"+department);
}
}