-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinh.java
More file actions
63 lines (62 loc) · 1.5 KB
/
Copy pathinh.java
File metadata and controls
63 lines (62 loc) · 1.5 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
import java.util.Scanner;
public class inh{
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
officer off=new officer();
manager man=new manager();
System.out.println("enter 1 for officer or 2 for manager");
int c=sc.nextInt();
sc.nextLine();
if(c==1){
System.out.println("OFFICER DETAILS");
off.name=sc.nextLine();
off.age=sc.nextInt();
sc.nextLine();
off.salary=sc.nextInt();
sc.nextLine();
off.specification=sc.nextLine();
off.displayofficer();
}
else if(c==2){
System.out.println("MANAGER DETAILS");
man.name=sc.nextLine();
man.age=sc.nextInt();
sc.nextLine();
man.salary=sc.nextInt();
sc.nextLine();
man.department=sc.nextLine();
man.displaymanager();
}
else{
System.out.println("error");
}
}
}
class employee{
String name;
int age;
int salary;
public void printsalary(){
System.out.println("salary:"+salary);
}
}
class officer extends employee{
String specification;
void displayofficer(){
System.out.println(" ");
System.out.println("name:"+name);
System.out.println("age:"+age);
System.out.println("salary:"+salary);
System.out.println("specification:"+specification);
}
}
class manager extends employee{
String department;
void displaymanager(){
System.out.println(" ");
System.out.println("name:"+name);
System.out.println("age:"+age);
System.out.println("salary:"+salary);
System.out.println("department:"+department);
}
}