-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathA6_6Employee.java
More file actions
41 lines (38 loc) · 1.11 KB
/
Copy pathA6_6Employee.java
File metadata and controls
41 lines (38 loc) · 1.11 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
package com.company;
abstract class Employee{
String name;
Employee(String name){
this.name=name;
}
public abstract void getamount();
}
class HourlyEmployee extends Employee{
float wage,hours; //wage: wage per hour, hours: number pf hours
HourlyEmployee(String name,float wage,float hours){
super(name);
this.wage=wage;
this.hours=hours;
}
public void getamount(){
System.out.println("The total amount paid is: "+wage*hours);
}
}
class WeeklyEmployee extends Employee{
float wage,weeks; //wage: wage per week, weeks: number of weeks
WeeklyEmployee(String name,float wage,float weeks){
super(name);
this.wage=wage;
this.weeks=weeks;
}
public void getamount(){
System.out.println("The total amount paid is: "+wage*weeks);
}
}
public class A6_6Employee {
public static void main(String[] args){
WeeklyEmployee A=new WeeklyEmployee("A",20000,9);
HourlyEmployee B=new HourlyEmployee("B",100,70);
A.getamount();
B.getamount();
}
}