大橙子网站建设,新征程启航

为企业提供网站建设、域名注册、服务器等服务

java中员工工资条代码,程序员工资条格式

JAVA编写一个为员工加薪的类(类与对象)

class Employee {

成都创新互联公司10多年企业网站制作服务;为您提供网站建设,网站制作,网页设计及高端网站定制服务,企业网站制作及推广,对成都搅拌罐车等多个方面拥有多年的网站营销经验的网站建设公司。

private String name;

private String department;

private double salary;

//构造方法

public Employee(String name, String department, double salary) {

this.name = name;

this.department = department;

this.salary = salary;

}

public String toString() {

return "姓名:" + name + "\t部门:" + department + "\t工资:" + salary;

}

public void raiseSalary(double per) {

this.salary = salary + salary * per;

}

public String getName() {

return name;

}

public void setName(String name) {

this.name = name;

}

public String getDepartment() {

return department;

}

public void setDepartment(String department) {

this.department = department;

}

public double getSalary() {

return salary;

}

public void setSalary(double salary) {

this.salary = salary;

}

}

public class TestEmployee {//测试类

public static void main(String[] args) {

Employee e1 = new Employee("张三", "技术开发部", 5000);

Employee e2 = new Employee("赵四", "后勤服务部", 3800);

Employee e3 = new Employee("王五", "产品营销部", 6800);

System.out.println(e1 + "\n" + e2 + "\n" + e3);

double per = 0.07;

e1.raiseSalary(per);

e2.raiseSalary(per);

e3.raiseSalary(per);

System.out.println("==============加薪7%===============");

System.out.println(e1 + "\n" + e2 + "\n" + e3);

}

}

输出

姓名:张三 部门:技术开发部 工资:5000.0

姓名:赵四 部门:后勤服务部 工资:3800.0

姓名:王五 部门:产品营销部 工资:6800.0

==============加薪7%===============

姓名:张三 部门:技术开发部 工资:5350.0

姓名:赵四 部门:后勤服务部 工资:4066.0

姓名:王五 部门:产品营销部 工资:7276.0

用java,编写五个人的工资表,计算出最高工资,平均数

import java.util.Arrays;

class YG implements ComparableYG{//员工类,实现比较接口

String name;//姓名

int gz;//工资

public YG(String name, int gz) {

this.name = name;

this.gz = gz;

}

public String toString() {

return "姓名:"+name+"\t工资:"+gz;

}

public int compareTo(YG o) {//通过这个方法, 实现按工资排序

return o.gz-this.gz;//从大到小

}

}

public class MyTest {

public static void main(String[] args) {

YG[] ary = new YG[5];

ary[0] = new YG("张三", 5260);

ary[1] = new YG("赵四", 6000);

ary[2] = new YG("王五", 5500);

ary[3] = new YG("唐六", 5800);

ary[4] = new YG("杨七", 5200);

Arrays.sort(ary);//排序

double sum = 0;

for (YG yg : ary) {

sum+=yg.gz;

}

System.out.println("最高工资:"+ary[0]+"\n平均工资:"+sum/ary.length);

}

}

输出

最高工资:姓名:赵四 工资:6000

平均工资:5552.0

使用java编写程序实现输入员工工资,获得员工的平均工资,要求使用象数组类型的

一:将员工姓名、工资封装成一个对象

public class Staff {

private String name;

private int salary;

public String getName() {

return name;

}

public void setName(String name) {

this.name = name;

}

public int getSalary() {

return salary;

}

public void setSalary(int salary) {

this.salary = salary;

}

public Staff(String name, int salary) {

super();

this.name = name;

this.salary = salary;

}

}

二:初始化一个数组,算平均工资

public class Average {

public static void main(String[] args) {

Staff staffs[] = {new Staff("zhangsan", 1000), new Staff("lisi", 1100), new Staff("wangwu", 1200)};

int sum = 0;

for(Staff staff : staffs) {

sum = sum + staff.getSalary();

}

System.out.println("员工人数:" + staffs.length + " 总工资:" + sum + " 平均工资:" + sum / staffs.length);

}

}

用JAVA编写一个处理学院员工月薪的应用程序的代码是什么?

abstract class Person{

private String name;

private String post;

Person(String name,String post){

this.name = name;

this.post = post;

}

public String getID(){

return (name+""+post);

}

public abstract double counting();

public void setName(String name){

this.name = name;

}

public String getName(){

return this.name;

}

public void setPost(String post){

this.post = post;

}

public String getPost(){

return this.post;

}

}

class Leader extends Person{

Leader(String name,String post){

super(name,post);

}

public double counting(){

return 3000d;

}

}

class Management extends Person{

private double basicWage=0d; //基本工资

private double allowance=0d; //津贴

Management(String name,String post){

super(name,post);

}

public void setBasicWage(double basicWage){

this.basicWage = basicWage;

}

public double getBasicWage(){

return this.basicWage;

}

public void setAllowance(double allowance){

this.allowance = allowance;

}

public double getAllowance(){

return this.allowance;

}

public double counting(){

return this.basicWage+this.allowance;

}

}

class Teacher extends Person{

private int hours; //课时

static final double ASSISTANT_STANDARD = 35.0d;//助教的课时收费标准

static final double LECTOR_STANDARD = 45.0d;//讲师的课时收费标准

static final double ANOTHER_STANDARD = 55.0d;//其他课时收费标准

Teacher (String name,String post){

super(name,post);

}

public double counting(){

double wage; //工资

if(this.getPost().equals("助教")){

wage = ASSISTANT_STANDARD*hours;

}else if(this.getPost().equals("讲师")){

wage = LECTOR_STANDARD * hours;

}else{

wage = ANOTHER_STANDARD * hours;

}

return wage;

}

public void setHours(int hours){

this.hours = hours;

}

public int getHours(){

return this.hours;

}

}

class Test {

public static void main(String [] args){

Leader leader = new Leader("张三","领导");

System.out.println(leader.getName()+"工资为:"+leader.counting());

Management manage = new Management("李四","管理人员");

manage.setBasicWage(1000d);

manage.setAllowance(500d);

System.out.println(manage.getName()+"工资为:"+manage.counting());

Teacher teacher = new Teacher("王五","助教");

teacher.setHours(50);

System.out.println(teacher.getName()+"工资为:"+teacher.counting());

Teacher teacher1 = new Teacher("赵六","讲师");

teacher1.setHours(60);

System.out.println(teacher1.getName()+"工资为:"+teacher1.counting

());

}

}

看下吧,有什么不足的请指出来


标题名称:java中员工工资条代码,程序员工资条格式
转载注明:http://dzwzjz.com/article/phihep.html
在线咨询
服务热线
服务热线:028-86922220
TOP