java算工资的编程题?

2024-11-23 12:26:27
推荐回答(1个)
回答1:

class Salary{
private int no;
private String name;
private double deal;
private double tax;
public Salary(int no,String name,double deal,double tax){
this.no=no;
this.name=name;
this.deal=deal;
this.tax=tax;
}
public double count(){
return this.deal-this.tax;
}
public void output(){
System.out.println("工号"+this.no);
System.out.println("姓名"+this.name);
System.out.println("应发工资"+this.deal);
System.out.println("税金"+this.tax);
System.out.println("实发工资"+count());
}
public static void main(String[] args){
Salary a=new Salary(1,"张三",1000,200);
a.output();
Salary b=new Salary(2,"李四",1500,200);
b.output();
}
}