Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
- package distance;
- /**
- *
- * @author t1406g_nvbang
- */
- /*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
- public class showResult {
- public static void main(String[] args) {
- Manager quanLy = new Manager("Nguyen Viet Bang", 10, 100);
- System.out.println(quanLy.calculatepay());
- Scientist nhaKhoaHoc = new Scientist("Nguyen Tan dung", 20000, 10);
- System.out.println(nhaKhoaHoc.calculatepay());
- Laborer congNhan = new Laborer("Ho chi minh", 2000000, 40);
- System.out.println(congNhan.calculatepay());
- }
- }
- class Employee {
- protected String name;
- protected double salary;
- public Employee (String eName, double eSalary) {
- name = eName;
- salary = eSalary;
- }
- public double calculatepay() {
- return 0;
- }
- }
- class Manager extends Employee {
- private double business_amount;
- public Manager(String mName, double mSalary, double mBusinessAmount) {
- super(mName, mSalary);
- business_amount = mBusinessAmount;
- }
- @Override
- public double calculatepay() {
- double total_pay;
- double commission;
- if (business_amount > 50000) {
- commission = business_amount/10;
- } else {
- commission = business_amount/20;
- }
- total_pay = salary + commission;
- return total_pay;
- }
- }
- //class
- class Scientist extends Employee {
- private int publication;
- public Scientist(String sName, double sSalary, int sPublication) {
- super(sName,sSalary);
- publication = sPublication;
- }
- @Override
- public double calculatepay() {
- double total_pay;
- total_pay = salary;
- if (publication > 25) {
- total_pay += salary/5;
- }
- else {
- total_pay += salary/10;
- }
- return total_pay;
- }
- }
- //class
- class Laborer extends Employee {
- private int hrsworked;
- public Laborer (String lName, double lSalary, int lHrsWorked) {
- super(lName, lSalary);
- hrsworked = lHrsWorked;
- }
- @Override
- public double calculatepay() {
- double total_pay;
- total_pay = salary;
- if (hrsworked > 50) {
- total_pay += salary/100*15;
- } else {
- total_pay += salary/100*8;
- }
- return total_pay;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement