-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpayroll.java
More file actions
62 lines (47 loc) · 1.23 KB
/
payroll.java
File metadata and controls
62 lines (47 loc) · 1.23 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
public class payroll {
public static void main(String[] args) {
Fulltime emp=new Fulltime(101, "hilo", 10000.0);
contractor ee=new contractor(201, "logwer", 100, 50.0);
emp.display();
ee.display();
}
}
abstract class Employee{
private int id;
private String name;
Employee(int id, String name){
this.id=id;
this.name=name;
}
abstract Double calculatesalary();
void display(){
System.out.println("ID : "+id);
System.out.println("name : "+name);
System.out.println("name : "+calculatesalary());
}
}
class Fulltime extends Employee{
int []history=new int[10];
int i=0;
Double monthlysalary;
Fulltime(int id,String name,Double monthlysalary){
super(id,name);
this.monthlysalary=monthlysalary;
}
Double calculatesalary(){
return monthlysalary;
}
}
class contractor extends Employee{
Double hourlyrate;
int hoursworked;
contractor(int id,String name,int hoursworked,Double hourlyrate){
super(id, name);
this.hourlyrate=hourlyrate;
this.hoursworked=hoursworked;
}
@Override
Double calculatesalary() {
return hourlyrate*hoursworked;
}
}