-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEmployee.java
More file actions
88 lines (79 loc) · 1.58 KB
/
Employee.java
File metadata and controls
88 lines (79 loc) · 1.58 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
import java.util.*;
class Emplyclass
{
Scanner sc=new Scanner(System.in);
String name;
int age;
int phno;
String address;
float salary;
void printSalary()
{
System.out.println("Salary: "+salary);
}
void read()
{
System.out.println("Enter name: ");
name=sc.nextLine();
System.out.println("Enter age: ");
age=sc.nextInt();
System.out.println("Enter Phno: ");
phno=sc.nextInt();
sc.nextLine();
System.out.println("Enter address: ");
address=sc.nextLine();
System.out.println("Enter salary: ");
salary=sc.nextFloat();
}
void print()
{
System.out.println(name);
System.out.println(age);
System.out.println(phno);
System.out.println(address);
}
}
class Officer extends Emplyclass
{
Scanner sc=new Scanner(System.in);
Emplyclass obj=new Emplyclass();
String Spclzn;
void printoff()
{
System.out.println("\n");
System.out.println("Enter Specialization: ");
Spclzn=sc.nextLine();
obj.read();
System.out.println("Officer:");
System.out.println("Specialization: "+Spclzn);
obj.print();
obj.printSalary();
}
}
class Manager extends Emplyclass
{
Scanner sc=new Scanner(System.in);
Emplyclass obj=new Emplyclass();
String Deprtmnt;
void printmang()
{
System.out.println("\n");
System.out.println("Enter Department: ");
Deprtmnt=sc.nextLine();
obj.read();
System.out.println("Manager");
System.out.println("Department: "+Deprtmnt);
obj.print();
obj.printSalary();
}
}
class Employee
{
public static void main(String args[])
{
Officer obj1=new Officer();
obj1.printoff();
Manager obj2=new Manager();
obj2.printmang();
}
}