Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
1.1 kB
0
Indexable
Never
package project;

abstract class Employee {
    protected String name;
    protected int id;
    abstract void calculateSalary(String name,int id);
}
class Manager extends Employee{
	protected int salary;
	protected int bonus;
	public void calculateSalary(String n,int i,int salary,int bonus) {
		name = name;
		id = i;
		this.salary = salary;
		this.bonus = bonus;
		int totalSalary = salary + bonus;
		System.out.println("Id : "+id);
		System.out.println("Name : "+name);
		System.out.println("Total Manager Salary : "+totalSalary);
	}
}
class Programmer extends Employee{
	protected int hours;
	protected int hoursRate;
	public void calculateSalary(String n,int i,int salary,int bonus) {
		name = name;
		id = i;
		this.salary = salary;
		this.bonus = bonus;
		int totalSalary = hours * hoursRate;
		System.out.println("Id : "+id);
		System.out.println("Name : "+name);
		System.out.println("Total Programmer Salary : "+totalSalary);
	}
}
public class Output{
	public static void main(String [] args) {
		Manager m = new Manager();
		m.calculateSalary("Al Sakib Ayon",28,50000,10000);
	}
}
Leave a Comment