-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCompany.java
More file actions
95 lines (70 loc) · 2.84 KB
/
Company.java
File metadata and controls
95 lines (70 loc) · 2.84 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
class Employee {
protected String name;
protected String address;
protected double salary;
protected String jobTitle;
public Employee(String name, String address, double salary, String jobTitle) {
this.name = name;
this.address = address;
this.salary = salary;
this.jobTitle = jobTitle;
}
public void generatePerformanceReport() {
System.out.println("Performance report for " + name + ":");
}
}
class Manager extends Employee {
private int numOfProjects;
public Manager(String name, String address, double salary, String jobTitle, int numOfProjects) {
super(name, address, salary, jobTitle);
this.numOfProjects = numOfProjects;
}
public void manageProjects() {
System.out.println(name + " is managing " + numOfProjects + " projects.");
}
public double calculateBonus() {
return salary * 0.1;
}
}
class Developer extends Employee {
private double percentCompletion;
public Developer(String name, String address, double salary, String jobTitle, double percentCompletion) {
super(name, address, salary, jobTitle);
this.percentCompletion = percentCompletion;
}
public void performanceCompletion() {
System.out.println(name + "'s performance completion: " + percentCompletion * 100 + "%");
}
public double calculateBonus() {
return salary * 0.05 * percentCompletion;
}
}
class Programmer extends Employee {
private int numOfHoursWorked;
public Programmer(String name, String address, double salary, String jobTitle, int numOfHoursWorked) {
super(name, address, salary, jobTitle);
this.numOfHoursWorked = numOfHoursWorked;
}
public void hoursWorked() {
System.out.println(name + " worked for " + numOfHoursWorked + " hours.");
}
public double calculateBonus() {
return numOfHoursWorked * 10;
}
}
public class Company {
public static void main(String[] args) {
Manager manager = new Manager("Rahul", "Kolkata", 80000, "Manager", 5);
Developer developer = new Developer("Rohan", "Mumbai", 70000, "Developer", 0.8);
Programmer programmer = new Programmer("Raman", "Delhi", 60000, "Programmer", 40);
manager.generatePerformanceReport();
manager.manageProjects();
System.out.println("Manager's bonus: $" + manager.calculateBonus());
developer.generatePerformanceReport();
developer.performanceCompletion();
System.out.println("Developer's bonus: $" + developer.calculateBonus());
programmer.generatePerformanceReport();
programmer.hoursWorked();
System.out.println("Programmer's bonus: $" + programmer.calculateBonus());
}
}