-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathemployee.java
More file actions
154 lines (122 loc) · 3.78 KB
/
Copy pathemployee.java
File metadata and controls
154 lines (122 loc) · 3.78 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
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
import java.util.*;
class staff{
int Id;
String Name;
float ph,sal;
staff(int id,String name,float ph,float sal){
Id = id;
Name = name;
this.ph = ph;
this.sal = sal;
}
//the display function
void display(){
System.out.println("Name: "+Name);
System.out.println("ID: "+Id);
System.out.println("Phone: "+ph);
System.out.println("Salary: "+sal);
}
}
class teaching extends staff{
String domain;
int publications;
teaching(int id,String name,float ph,float sal,String tdomain,int tpublications){
super(id,name,ph,sal);
domain = tdomain;
publications = tpublications;
}
void display(){
super.display();
System.out.println("Domain: "+domain);
System.out.println("Publications: "+publications);
}
}
class technical extends staff{
String skills;
technical(int id,String name,float ph,float sal, String skills){
super(id, name, ph, sal);
this.skills=skills;
}
void display(){
super.display();
System.out.println("Skills: "+skills);
}
}
class contract extends staff{
int period;
contract(int id,String name,float ph,float sal, int periods){
super(id, name, ph, sal);
period= periods;
}
void display(){
super.display();
System.out.println("Periods: "+period);
}
}
class employee{
public static void main(String args[]){
//declaring
int i;
String name,domain,skills;
int id,publications,period;
float ph,sal;
teaching t[] = new teaching[3];
technical te[] = new technical[3];
contract c[] = new contract[3];
Scanner sc = new Scanner(System.in);
//technical
for(i=0;i<1;i++){
System.out.println("enter the name");
name = sc.next();
System.out.println("enter the phn");
ph = sc.nextFloat();
System.out.println("enter the id");
id = sc.nextInt();
System.out.println("enter the sal");
sal = sc.nextFloat();
System.out.println("enter the skills");
skills = sc.next();
te[i] = new technical(id, name, ph, sal, skills);
}
//teaching
for(i=0;i<1;i++){
System.out.println("enter the name");
name = sc.next();
System.out.println("enter the phn");
ph = sc.nextFloat();
System.out.println("enter the id");
id = sc.nextInt();
System.out.println("enter the sal");
sal = sc.nextFloat();
System.out.println("enter the domain");
domain = sc.next();
System.out.println("enter the publications");
publications = sc.nextInt();
t[i] = new teaching(id, name, ph, sal, domain, publications);
}
//contract
for(i=0;i<1;i++){
System.out.println("enter the name");
name = sc.next();
System.out.println("enter the phn");
ph = sc.nextFloat();
System.out.println("enter the id");
id = sc.nextInt();
System.out.println("enter the sal");
sal = sc.nextFloat();
System.out.println("enter the period");
period = sc.nextInt();
c[i] = new contract(id, name, ph, sal, period);
}
//displaying each of them
for(i=0;i<1;i++){
t[i].display();
}
for(i=0;i<1;i++){
te[i].display();
}
for(i=0;i<1;i++){
c[i].display();
}
}
}