-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathEmployee.java
More file actions
75 lines (52 loc) · 1.48 KB
/
Copy pathEmployee.java
File metadata and controls
75 lines (52 loc) · 1.48 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
import java.util.Scanner;
public class Employee {
String Name,Phone_Number,Address;
int Age,Salary;
void print_Salary() {
System.out.println("Salary : "+Salary);
}
public static void main(String args[]) {
Scanner scn = new Scanner(System.in);
Officer of = new Officer();
Manager mg = new Manager();
System.out.println("\nOfficer\n");
of.input();
System.out.println("Enter the specialization");
of.specialization = scn.next();
System.out.println("\nManager\n");
mg.input();
System.out.println("Enter the department");
mg.Department = scn.next();
System.out.println("\nOfficer\n");
of.print();
System.out.println("Specialization : "+of.specialization);
System.out.println("\nManager\n");
mg.print();
System.out.println("Department "+mg.Department);
scn.close();
}
void input() {
Scanner sc = new Scanner(System.in);
System.out.println("Enter the Name :");
Name = sc.next();
System.out.println("Enter the Address :");
Address = sc.next();
System.out.println("Enter the Phone_Number :");
Phone_Number = sc.next();
System.out.println("Enter the Age :");
Age = sc.nextInt();
System.out.println("Enter the Salary :");
Salary = sc.nextInt();
sc.nextLine();
}
void print() {
System.out.println("\nName : "+Name+"\nAge : "+Age+"\nAddress : "+Address+"\nPhone_Number : "+Phone_Number);
print_Salary();
}
}
class Officer extends Employee {
String specialization;
}
class Manager extends Employee {
String Department;
}