工资支付程序

2023-02-03 22:08:24   文档大全网     [ 字体: ] [ 阅读: ]

#文档大全网# 导语】以下是®文档大全网的小编为您整理的《工资支付程序》,欢迎阅读!
工资,支付,程序
假定要为某个公司编写雇员工资支付程序。这个公司有各种类型的雇员(Employee),不同类型的雇员按不同的方式支付工资:

经理(Manager):每月获得一份固定的工资;

销售人员(Salesman):在基本工资的基础上每月还有销售提成; 一般工人(Worker):则按他每月工作的天数计算工资。

试用类的继承及相关机制描述这些功能需求,并编写一个Java Application程序,演示这些类的用法。

abstract class Employee{ String name;

public Employee(String name){ this.name=name; }

public abstract double computeSalary(); }

class Manager extends Employee{ int gdsalary;

public Manager(String a,int b){ super(a); gdsalary=b; }

public double computeSalary(){ return gdsalary; } }

class Salesman extends Employee{ int jibengongzi; int ticheng;

public Salesman(String a, int b,int c){ super(a); jibengongzi=b; ticheng=c; }

public double computeSalary(){ return jibengongzi+ticheng; } }

class Worker extends Employee{ int rigongzi; int days;

public Worker(String a,int b,int c){ super(a); rigongzi=b;


days=c; }

public double computeSalary(){ return rigongzi*days; } }

public class Test{

public static void main(String args[]){ Manager a=new Manager("Tom",10000); Salesman b=new Salesman("Jack",2000,3620); Worker c=new Worker("Mary",36,25);

System.out.println(a.name+"的工资是:"+a.computeSalary()); System.out.println(b.name+"的工资是:"+b.computeSalary()); System.out.println(c.name+"的工资是:"+c.computeSalary()); } }




本文来源:https://www.wddqxz.cn/727312531411cc7931b765ce05087632311274de.html

相关推荐