You are on page 1of 4

## main

package java.lab.assignment;
import java.util.Scanner;
public class Main {
public static Scanner in = new Scanner(System.in);
public static void main(String[] args) {
Employee[] E = new Employee[3];
E[0] = new SalariedEmployee(12); // Weekly per dolar
E[1] = new HourlyEmployee(3, 23); // Hourly
E[2] = new CommionEmployee(15, 10); /// Percentence %
System.out.println(E[0].getting());
System.out.println(E[1].getting());
System.out.println(E[2].getting());
}
}

abstract class Employee{


public abstract double getting();
public abstract void setting();
}

/* from here the weekly paid Empolyee starts */

class SalariedEmployee extends Employee{


double income;
public SalariedEmployee(double rate){
income = rate;
}
public void bonus(double persent){
income += (persent/100.00);
}
@Override
public void setting() {
; // NO need to use this one ...
}
@Override
public double getting() {
return income;
}
}

/* from here the Hourly paid Empolyee starts */

class HourlyEmployee extends Employee{


double income;
public HourlyEmployee(double hour, double rate){
income = hour*rate;
}
@Override
public double getting() {
return income;
}
@Override
public void setting() {
;
}
}

/* from here the commision based paid Empolyee starts */

class CommionEmployee extends Employee{


double income; // Total income as per instance variable;
public CommionEmployee(double a, double b){
income = b + a*(b/100.00);
}
@Override
public double getting() {
return income;
}
@Override
public void setting() {
;
}
}

You might also like