-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstaff detail.txt
170 lines (134 loc) · 3.75 KB
/
staff detail.txt
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
Design a super class called Staff with details as StaffId, Name, Phone, Salary. Extend this class by writing three subclasses namely
Teaching (domain, publications), Technical (skills), and Contract (period).
Write a Java program to read and display at least 3 staff objects of all three categorie.
import java.util.Scanner;
class Staff
{
String StaffID, Name, Phone, Salary;
Scanner input = new Scanner(System.in);
void read()
{
System.out.println("Enter StaffID");
StaffID = input.nextLine();
System.out.println("Enter Name");
Name = input.nextLine();
System.out.println("Enter Phone");
Phone = input.nextLine();
System.out.println("Enter Salary");
Salary = input.nextLine();
}
void display()
{
System.out.printf("\n%-15s", "STAFFID: ");
System.out.printf("%-15s \n", StaffID);
System.out.printf("%-15s", "NAME: ");
System.out.printf("%-15s \n", Name);
System.out.printf("%-15s", "PHONE:");
System.out.printf("%-15s \n", Phone);
System.out.printf("%-15s", "SALARY:");
System.out.printf("%-15s \n", Salary);
}
}
class Teaching extends Staff
{
String Domain, Publication;
void read_Teaching()
{
super.read(); // call super class read method
System.out.println("Enter Domain");
Domain = input.nextLine();
System.out.println("Enter Publication");
Publication = input.nextLine();
}
void display()
{
super.display(); // call super class display() method
System.out.printf("%-15s", "DOMAIN:");
System.out.printf("%-15s \n", Domain);
System.out.printf("%-15s", "PUBLICATION:");
System.out.printf("%-15s \n", Publication);
}
}
class Technical extends Staff
{
String Skills;
void read_Technical()
{
super.read(); // call super class read method
System.out.println("Enter Skills");
Skills = input.nextLine();
}
void display()
{
super.display(); // call super class display() method
System.out.printf("%-15s", "SKILLS:");
System.out.printf("%-15s \n", Skills);
}
}
class Contract extends Staff
{
String Period;
void read_Contract()
{
super.read(); // call super class read method
System.out.println("Enter Period");
Period = input.nextLine();
}
void display()
{
super.display(); // call super class display() method
System.out.printf("%-15s", "PERIOD:");
System.out.printf("%-15s \n", Period);
}
}
class Staffdetails
{
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
System.out.println("Enter number of staff details to be created");
int n = input.nextInt();
Teaching steach[] = new Teaching[n];
Technical stech[] = new Technical[n];
Contract scon[] = new Contract[n];
// Read Staff information under 3 categories
for (int i = 0; i < n; i++)
{
System.out.println("Enter Teaching staff information");
steach[i] = new Teaching();
steach[i].read_Teaching();
}
for (int i = 0; i < n; i++)
{
System.out.println("Enter Technical staff information");
stech[i] = new Technical();
stech[i].read_Technical();
}
for (int i = 0; i < n; i++)
{
System.out.println("Enter Contract staff information");
scon[i] = new Contract();
scon[i].read_Contract();
}
// Display Staff Information
System.out.println("\n STAFF DETAILS: \n");
System.out.println("-----TEACHING STAFF DETAILS----- ");
for (int i = 0; i < n; i++)
{
steach[i].display();
}
System.out.println();
System.out.println("-----TECHNICAL STAFF DETAILS-----");
for (int i = 0; i < n; i++)
{
stech[i].display();
}
System.out.println();
System.out.println("-----CONTRACT STAFF DETAILS-----");
for (int i = 0; i < n; i++)
{
scon[i].display();
}
input.close();
}
}