Flask接口签名sign原理与实例代码浅析
270
2022-08-25
Java实现简单员工管理系统
本文实例为大家分享了java实现简单员工管理系统的具体代码,供大家参考,具体内容如下
代码如下:
import java.util.*;
public class Demo {
public static void main(String[] args) {
EmpManage em = new EmpManage();
while (true) {
System.out.println("==================员工管理系统====================");
System.out.println("==================0.加载原有信息==================");
System.out.println("==================1.加入员工=====================");
System.out.println("==================2.删除员工=====================");
System.out.println("==================3.查询员工信息==================");
System.out.println("==================4.修改员工薪水 ==================");
System.out.println("==================5.薪水排序======================");
System.out.println("==================6.平均工资、最低与最高工资=======");
System.out.println("==================7.打印全体员工信息==============");
System.out.println("==================8.退出系统=====================");
System.out.print("请选择功能【0~8】:");
Scanner reader = new Scanner(System.in);
int x;
x = reader.nextInt();
switch (x) {
case 0:
Employee e1 = new Employee("2001","轩辕戈",2http://002f);
Employee f = new Employee("2002","季长风",4500f);
Employee g = new Employee("2003","鱼幼薇",2560f);
Employee h = new Employee("2004","李小龙",1604f);
em.addEmp(e1);
em.addEmp(f);
em.addEmp(g);
em.addEmp(h);
System.out.println("加载完毕!");
break;
case 1:
System.out.println("请输入要增加员工的信息(编号,姓名,薪水中间用空格隔开)");
String a, b;
float c;
a = reader.next();
b = reader.next();
c = reader.nextFloat();
Employee e = new Employee(a, b, c);
em.addEmp(e);
System.out.println("加入成功!");
break;
case 2:
System.out.print("请输入要刪除員工的编号:");
String y;
y=reader.next();
em.deleteEmp(y);
System.out.println("删除成功!");
break;
case 3:
System.out.print("请输入要查询員工的编号:");
String z;
z=reader.next();
em.showinfo(z);
break;
case 4:
System.out.print("请输入要修改員工的编号:");
String w;
w=reader.next();
System.out.print("请输入要修改成的工资数目:");
float v;
v=reader.nextFloat();
em.changesal(w, v);
System.out.println("修改成功!");
break;
case 5:
System.out.println("1.按薪水从高到低的顺序排序");
System.out.println("2.按薪水从低到高的顺序排序");
System.out.print("请选择功能【1~2】:");
int t;
t=reader.nextInt();
if(t==1)
{
em.sorthl();
}
if(t==2)
{
em.sortlh();
}
break;
case 6:
em.hlsal();
break;
case 7:
em.showAll();
break;
case 8:
System.out.println("程序已经运行结束,下次见!");
System.exit(0);
break;
default:
System.out.print("数字范围只能在1~8之间!");
}
}
}
}
//雇员管理类
class EmpManage
{
private ArrayList al=null;
//构造方法
public EmpManage() {
al=new ArrayList();
}
//加入员工方法
public void addEmp(Employee e)
{
al.add(e);
}
//刪除员工
public void deleteEmp(String x)
{
int i;
for(i=0;i { Employee temp=(Employee)al.get(i); if(temp.getEmNo().equals(x)) break; } al.remove(i-1); } //根据员工号显示该员工的信息 public void showinfo(String emNo) { //遍历整个ArrayList for(int i=0;i { Employee em=(Employee)al.get(i); if(em.getEmNo().equals(emNo)) { System.out.println("编号:"+em.getEmNo()+" "+"姓名:"+em.getName()+" "+"工资:"+em.getSal()); } } } //修改员工的薪水 public void changesal(String x,float y) { for(int i=0;i { Employee em=(Employee) al.get(i); if(em.getEmNo().equals(x)) { em.setSal(y); } } } //根据员工的薪水进行排序(从高到低) public void sorthl() { String a,b; float c; for(int i=0;i { Employee e=(Employee)al.get(i); for(int j=i+1;j { Employee m=(Employee)al.get(j); if(e.getSal() { a=e.getEmNo(); e.setEmNo(m.getEmNo()); m.setEmNo(a); b=e.getName(); e.setName(m.getName()); m.setName(b); c=e.getSal(); e.setSal(m.getSal()); m.setSal(c); } } } System.out.println("排序成功!"); System.out.println("打印信息如下:"); showAll(); } //根据员工的薪水进行排序(从低到高) public void sortlh() { String a,b; float c; for(int i=0;i { Employee e=(Employee)al.get(i); for(int j=i+1;j { Employee m=(Employee)al.get(j); if(e.getSal()>m.getSal()) { a=e.getEmNo(); e.setEmNo(m.getEmNo()); m.setEmNo(a); b=e.getName(); e.setName(m.getName()); m.setName(b); c=e.getSal(); e.setSal(m.getSal()); m.setSal(c); } } } System.out.println("排序成功!"); System.out.println("打印信息如下:"); showAll(); } //平均工资、最高与最低工资 public void hlsal() { float x=0,h,l=0; for(int i=0;i { Employee e=(Employee)al.get(i); x=x+e.getSal(); } System.out.println("平均工资:"+x/al.size()); Employee s=(Employee)al.get(0); h=s.getSal(); l=s.getSal(); for(int i=0;i { Employee v=(Employee)al.get(i); if(v.getSal()>h) h=v.getSal(); if(v.getSal() l=v.getSal(); } System.out.println("最高工资:"+h); System.out.println("最低工资:"+l); } //显示所有员工的信息 public void showAll() { for(int i=0;i { Employee em=(Employee)al.get(i); System.out.println("第"+(i+1)+"个员工: "+"编号:"+em.getEmNo()+" "+"姓名:"+em.getName()+" "+"工资:"+em.getSal()); } } } //员工类 class Employee { private String emNo; private String name; private float sal; // 构造方法 public Employee(String emNo, String name, float sal) { super(); this.emNo = emNo; this.name = name; this.sal = sal; } // 所有的getter和setter方法 public String getEmNo() { return emNo; } public void setEmNo(String emNo) { this.emNo = emNo; } public String getName() { return name; } public void setName(String name) { this.name = name; } public float getSal() { return sal; } public void setSal(float sal) { this.sal = sal; } } 运行示例:
{
Employee temp=(Employee)al.get(i);
if(temp.getEmNo().equals(x))
break;
}
al.remove(i-1);
}
//根据员工号显示该员工的信息
public void showinfo(String emNo)
{
//遍历整个ArrayList
for(int i=0;i { Employee em=(Employee)al.get(i); if(em.getEmNo().equals(emNo)) { System.out.println("编号:"+em.getEmNo()+" "+"姓名:"+em.getName()+" "+"工资:"+em.getSal()); } } } //修改员工的薪水 public void changesal(String x,float y) { for(int i=0;i { Employee em=(Employee) al.get(i); if(em.getEmNo().equals(x)) { em.setSal(y); } } } //根据员工的薪水进行排序(从高到低) public void sorthl() { String a,b; float c; for(int i=0;i { Employee e=(Employee)al.get(i); for(int j=i+1;j { Employee m=(Employee)al.get(j); if(e.getSal() { a=e.getEmNo(); e.setEmNo(m.getEmNo()); m.setEmNo(a); b=e.getName(); e.setName(m.getName()); m.setName(b); c=e.getSal(); e.setSal(m.getSal()); m.setSal(c); } } } System.out.println("排序成功!"); System.out.println("打印信息如下:"); showAll(); } //根据员工的薪水进行排序(从低到高) public void sortlh() { String a,b; float c; for(int i=0;i { Employee e=(Employee)al.get(i); for(int j=i+1;j { Employee m=(Employee)al.get(j); if(e.getSal()>m.getSal()) { a=e.getEmNo(); e.setEmNo(m.getEmNo()); m.setEmNo(a); b=e.getName(); e.setName(m.getName()); m.setName(b); c=e.getSal(); e.setSal(m.getSal()); m.setSal(c); } } } System.out.println("排序成功!"); System.out.println("打印信息如下:"); showAll(); } //平均工资、最高与最低工资 public void hlsal() { float x=0,h,l=0; for(int i=0;i { Employee e=(Employee)al.get(i); x=x+e.getSal(); } System.out.println("平均工资:"+x/al.size()); Employee s=(Employee)al.get(0); h=s.getSal(); l=s.getSal(); for(int i=0;i { Employee v=(Employee)al.get(i); if(v.getSal()>h) h=v.getSal(); if(v.getSal() l=v.getSal(); } System.out.println("最高工资:"+h); System.out.println("最低工资:"+l); } //显示所有员工的信息 public void showAll() { for(int i=0;i { Employee em=(Employee)al.get(i); System.out.println("第"+(i+1)+"个员工: "+"编号:"+em.getEmNo()+" "+"姓名:"+em.getName()+" "+"工资:"+em.getSal()); } } } //员工类 class Employee { private String emNo; private String name; private float sal; // 构造方法 public Employee(String emNo, String name, float sal) { super(); this.emNo = emNo; this.name = name; this.sal = sal; } // 所有的getter和setter方法 public String getEmNo() { return emNo; } public void setEmNo(String emNo) { this.emNo = emNo; } public String getName() { return name; } public void setName(String name) { this.name = name; } public float getSal() { return sal; } public void setSal(float sal) { this.sal = sal; } } 运行示例:
{
Employee em=(Employee)al.get(i);
if(em.getEmNo().equals(emNo))
{
System.out.println("编号:"+em.getEmNo()+" "+"姓名:"+em.getName()+" "+"工资:"+em.getSal());
}
}
}
//修改员工的薪水
public void changesal(String x,float y)
{
for(int i=0;i { Employee em=(Employee) al.get(i); if(em.getEmNo().equals(x)) { em.setSal(y); } } } //根据员工的薪水进行排序(从高到低) public void sorthl() { String a,b; float c; for(int i=0;i { Employee e=(Employee)al.get(i); for(int j=i+1;j { Employee m=(Employee)al.get(j); if(e.getSal() { a=e.getEmNo(); e.setEmNo(m.getEmNo()); m.setEmNo(a); b=e.getName(); e.setName(m.getName()); m.setName(b); c=e.getSal(); e.setSal(m.getSal()); m.setSal(c); } } } System.out.println("排序成功!"); System.out.println("打印信息如下:"); showAll(); } //根据员工的薪水进行排序(从低到高) public void sortlh() { String a,b; float c; for(int i=0;i { Employee e=(Employee)al.get(i); for(int j=i+1;j { Employee m=(Employee)al.get(j); if(e.getSal()>m.getSal()) { a=e.getEmNo(); e.setEmNo(m.getEmNo()); m.setEmNo(a); b=e.getName(); e.setName(m.getName()); m.setName(b); c=e.getSal(); e.setSal(m.getSal()); m.setSal(c); } } } System.out.println("排序成功!"); System.out.println("打印信息如下:"); showAll(); } //平均工资、最高与最低工资 public void hlsal() { float x=0,h,l=0; for(int i=0;i { Employee e=(Employee)al.get(i); x=x+e.getSal(); } System.out.println("平均工资:"+x/al.size()); Employee s=(Employee)al.get(0); h=s.getSal(); l=s.getSal(); for(int i=0;i { Employee v=(Employee)al.get(i); if(v.getSal()>h) h=v.getSal(); if(v.getSal() l=v.getSal(); } System.out.println("最高工资:"+h); System.out.println("最低工资:"+l); } //显示所有员工的信息 public void showAll() { for(int i=0;i { Employee em=(Employee)al.get(i); System.out.println("第"+(i+1)+"个员工: "+"编号:"+em.getEmNo()+" "+"姓名:"+em.getName()+" "+"工资:"+em.getSal()); } } } //员工类 class Employee { private String emNo; private String name; private float sal; // 构造方法 public Employee(String emNo, String name, float sal) { super(); this.emNo = emNo; this.name = name; this.sal = sal; } // 所有的getter和setter方法 public String getEmNo() { return emNo; } public void setEmNo(String emNo) { this.emNo = emNo; } public String getName() { return name; } public void setName(String name) { this.name = name; } public float getSal() { return sal; } public void setSal(float sal) { this.sal = sal; } } 运行示例:
{
Employee em=(Employee) al.get(i);
if(em.getEmNo().equals(x))
{
em.setSal(y);
}
}
}
//根据员工的薪水进行排序(从高到低)
public void sorthl()
{
String a,b;
float c;
for(int i=0;i { Employee e=(Employee)al.get(i); for(int j=i+1;j { Employee m=(Employee)al.get(j); if(e.getSal() { a=e.getEmNo(); e.setEmNo(m.getEmNo()); m.setEmNo(a); b=e.getName(); e.setName(m.getName()); m.setName(b); c=e.getSal(); e.setSal(m.getSal()); m.setSal(c); } } } System.out.println("排序成功!"); System.out.println("打印信息如下:"); showAll(); } //根据员工的薪水进行排序(从低到高) public void sortlh() { String a,b; float c; for(int i=0;i { Employee e=(Employee)al.get(i); for(int j=i+1;j { Employee m=(Employee)al.get(j); if(e.getSal()>m.getSal()) { a=e.getEmNo(); e.setEmNo(m.getEmNo()); m.setEmNo(a); b=e.getName(); e.setName(m.getName()); m.setName(b); c=e.getSal(); e.setSal(m.getSal()); m.setSal(c); } } } System.out.println("排序成功!"); System.out.println("打印信息如下:"); showAll(); } //平均工资、最高与最低工资 public void hlsal() { float x=0,h,l=0; for(int i=0;i { Employee e=(Employee)al.get(i); x=x+e.getSal(); } System.out.println("平均工资:"+x/al.size()); Employee s=(Employee)al.get(0); h=s.getSal(); l=s.getSal(); for(int i=0;i { Employee v=(Employee)al.get(i); if(v.getSal()>h) h=v.getSal(); if(v.getSal() l=v.getSal(); } System.out.println("最高工资:"+h); System.out.println("最低工资:"+l); } //显示所有员工的信息 public void showAll() { for(int i=0;i { Employee em=(Employee)al.get(i); System.out.println("第"+(i+1)+"个员工: "+"编号:"+em.getEmNo()+" "+"姓名:"+em.getName()+" "+"工资:"+em.getSal()); } } } //员工类 class Employee { private String emNo; private String name; private float sal; // 构造方法 public Employee(String emNo, String name, float sal) { super(); this.emNo = emNo; this.name = name; this.sal = sal; } // 所有的getter和setter方法 public String getEmNo() { return emNo; } public void setEmNo(String emNo) { this.emNo = emNo; } public String getName() { return name; } public void setName(String name) { this.name = name; } public float getSal() { return sal; } public void setSal(float sal) { this.sal = sal; } } 运行示例:
{
Employee e=(Employee)al.get(i);
for(int j=i+1;j { Employee m=(Employee)al.get(j); if(e.getSal() { a=e.getEmNo(); e.setEmNo(m.getEmNo()); m.setEmNo(a); b=e.getName(); e.setName(m.getName()); m.setName(b); c=e.getSal(); e.setSal(m.getSal()); m.setSal(c); } } } System.out.println("排序成功!"); System.out.println("打印信息如下:"); showAll(); } //根据员工的薪水进行排序(从低到高) public void sortlh() { String a,b; float c; for(int i=0;i { Employee e=(Employee)al.get(i); for(int j=i+1;j { Employee m=(Employee)al.get(j); if(e.getSal()>m.getSal()) { a=e.getEmNo(); e.setEmNo(m.getEmNo()); m.setEmNo(a); b=e.getName(); e.setName(m.getName()); m.setName(b); c=e.getSal(); e.setSal(m.getSal()); m.setSal(c); } } } System.out.println("排序成功!"); System.out.println("打印信息如下:"); showAll(); } //平均工资、最高与最低工资 public void hlsal() { float x=0,h,l=0; for(int i=0;i { Employee e=(Employee)al.get(i); x=x+e.getSal(); } System.out.println("平均工资:"+x/al.size()); Employee s=(Employee)al.get(0); h=s.getSal(); l=s.getSal(); for(int i=0;i { Employee v=(Employee)al.get(i); if(v.getSal()>h) h=v.getSal(); if(v.getSal() l=v.getSal(); } System.out.println("最高工资:"+h); System.out.println("最低工资:"+l); } //显示所有员工的信息 public void showAll() { for(int i=0;i { Employee em=(Employee)al.get(i); System.out.println("第"+(i+1)+"个员工: "+"编号:"+em.getEmNo()+" "+"姓名:"+em.getName()+" "+"工资:"+em.getSal()); } } } //员工类 class Employee { private String emNo; private String name; private float sal; // 构造方法 public Employee(String emNo, String name, float sal) { super(); this.emNo = emNo; this.name = name; this.sal = sal; } // 所有的getter和setter方法 public String getEmNo() { return emNo; } public void setEmNo(String emNo) { this.emNo = emNo; } public String getName() { return name; } public void setName(String name) { this.name = name; } public float getSal() { return sal; } public void setSal(float sal) { this.sal = sal; } } 运行示例:
{
Employee m=(Employee)al.get(j);
if(e.getSal() { a=e.getEmNo(); e.setEmNo(m.getEmNo()); m.setEmNo(a); b=e.getName(); e.setName(m.getName()); m.setName(b); c=e.getSal(); e.setSal(m.getSal()); m.setSal(c); } } } System.out.println("排序成功!"); System.out.println("打印信息如下:"); showAll(); } //根据员工的薪水进行排序(从低到高) public void sortlh() { String a,b; float c; for(int i=0;i { Employee e=(Employee)al.get(i); for(int j=i+1;j { Employee m=(Employee)al.get(j); if(e.getSal()>m.getSal()) { a=e.getEmNo(); e.setEmNo(m.getEmNo()); m.setEmNo(a); b=e.getName(); e.setName(m.getName()); m.setName(b); c=e.getSal(); e.setSal(m.getSal()); m.setSal(c); } } } System.out.println("排序成功!"); System.out.println("打印信息如下:"); showAll(); } //平均工资、最高与最低工资 public void hlsal() { float x=0,h,l=0; for(int i=0;i { Employee e=(Employee)al.get(i); x=x+e.getSal(); } System.out.println("平均工资:"+x/al.size()); Employee s=(Employee)al.get(0); h=s.getSal(); l=s.getSal(); for(int i=0;i { Employee v=(Employee)al.get(i); if(v.getSal()>h) h=v.getSal(); if(v.getSal() l=v.getSal(); } System.out.println("最高工资:"+h); System.out.println("最低工资:"+l); } //显示所有员工的信息 public void showAll() { for(int i=0;i { Employee em=(Employee)al.get(i); System.out.println("第"+(i+1)+"个员工: "+"编号:"+em.getEmNo()+" "+"姓名:"+em.getName()+" "+"工资:"+em.getSal()); } } } //员工类 class Employee { private String emNo; private String name; private float sal; // 构造方法 public Employee(String emNo, String name, float sal) { super(); this.emNo = emNo; this.name = name; this.sal = sal; } // 所有的getter和setter方法 public String getEmNo() { return emNo; } public void setEmNo(String emNo) { this.emNo = emNo; } public String getName() { return name; } public void setName(String name) { this.name = name; } public float getSal() { return sal; } public void setSal(float sal) { this.sal = sal; } } 运行示例:
{
a=e.getEmNo();
e.setEmNo(m.getEmNo());
m.setEmNo(a);
b=e.getName();
e.setName(m.getName());
m.setName(b);
c=e.getSal();
e.setSal(m.getSal());
m.setSal(c);
}
}
}
System.out.println("排序成功!");
System.out.println("打印信息如下:");
showAll();
}
//根据员工的薪水进行排序(从低到高)
public void sortlh()
{
String a,b;
float c;
for(int i=0;i { Employee e=(Employee)al.get(i); for(int j=i+1;j { Employee m=(Employee)al.get(j); if(e.getSal()>m.getSal()) { a=e.getEmNo(); e.setEmNo(m.getEmNo()); m.setEmNo(a); b=e.getName(); e.setName(m.getName()); m.setName(b); c=e.getSal(); e.setSal(m.getSal()); m.setSal(c); } } } System.out.println("排序成功!"); System.out.println("打印信息如下:"); showAll(); } //平均工资、最高与最低工资 public void hlsal() { float x=0,h,l=0; for(int i=0;i { Employee e=(Employee)al.get(i); x=x+e.getSal(); } System.out.println("平均工资:"+x/al.size()); Employee s=(Employee)al.get(0); h=s.getSal(); l=s.getSal(); for(int i=0;i { Employee v=(Employee)al.get(i); if(v.getSal()>h) h=v.getSal(); if(v.getSal() l=v.getSal(); } System.out.println("最高工资:"+h); System.out.println("最低工资:"+l); } //显示所有员工的信息 public void showAll() { for(int i=0;i { Employee em=(Employee)al.get(i); System.out.println("第"+(i+1)+"个员工: "+"编号:"+em.getEmNo()+" "+"姓名:"+em.getName()+" "+"工资:"+em.getSal()); } } } //员工类 class Employee { private String emNo; private String name; private float sal; // 构造方法 public Employee(String emNo, String name, float sal) { super(); this.emNo = emNo; this.name = name; this.sal = sal; } // 所有的getter和setter方法 public String getEmNo() { return emNo; } public void setEmNo(String emNo) { this.emNo = emNo; } public String getName() { return name; } public void setName(String name) { this.name = name; } public float getSal() { return sal; } public void setSal(float sal) { this.sal = sal; } } 运行示例:
{
Employee e=(Employee)al.get(i);
for(int j=i+1;j { Employee m=(Employee)al.get(j); if(e.getSal()>m.getSal()) { a=e.getEmNo(); e.setEmNo(m.getEmNo()); m.setEmNo(a); b=e.getName(); e.setName(m.getName()); m.setName(b); c=e.getSal(); e.setSal(m.getSal()); m.setSal(c); } } } System.out.println("排序成功!"); System.out.println("打印信息如下:"); showAll(); } //平均工资、最高与最低工资 public void hlsal() { float x=0,h,l=0; for(int i=0;i { Employee e=(Employee)al.get(i); x=x+e.getSal(); } System.out.println("平均工资:"+x/al.size()); Employee s=(Employee)al.get(0); h=s.getSal(); l=s.getSal(); for(int i=0;i { Employee v=(Employee)al.get(i); if(v.getSal()>h) h=v.getSal(); if(v.getSal() l=v.getSal(); } System.out.println("最高工资:"+h); System.out.println("最低工资:"+l); } //显示所有员工的信息 public void showAll() { for(int i=0;i { Employee em=(Employee)al.get(i); System.out.println("第"+(i+1)+"个员工: "+"编号:"+em.getEmNo()+" "+"姓名:"+em.getName()+" "+"工资:"+em.getSal()); } } } //员工类 class Employee { private String emNo; private String name; private float sal; // 构造方法 public Employee(String emNo, String name, float sal) { super(); this.emNo = emNo; this.name = name; this.sal = sal; } // 所有的getter和setter方法 public String getEmNo() { return emNo; } public void setEmNo(String emNo) { this.emNo = emNo; } public String getName() { return name; } public void setName(String name) { this.name = name; } public float getSal() { return sal; } public void setSal(float sal) { this.sal = sal; } } 运行示例:
{
Employee m=(Employee)al.get(j);
if(e.getSal()>m.getSal())
{
a=e.getEmNo();
e.setEmNo(m.getEmNo());
m.setEmNo(a);
b=e.getName();
e.setName(m.getName());
m.setName(b);
c=e.getSal();
e.setSal(m.getSal());
m.setSal(c);
}
}
}
System.out.println("排序成功!");
System.out.println("打印信息如下:");
showAll();
}
//平均工资、最高与最低工资
public void hlsal()
{
float x=0,h,l=0;
for(int i=0;i { Employee e=(Employee)al.get(i); x=x+e.getSal(); } System.out.println("平均工资:"+x/al.size()); Employee s=(Employee)al.get(0); h=s.getSal(); l=s.getSal(); for(int i=0;i { Employee v=(Employee)al.get(i); if(v.getSal()>h) h=v.getSal(); if(v.getSal() l=v.getSal(); } System.out.println("最高工资:"+h); System.out.println("最低工资:"+l); } //显示所有员工的信息 public void showAll() { for(int i=0;i { Employee em=(Employee)al.get(i); System.out.println("第"+(i+1)+"个员工: "+"编号:"+em.getEmNo()+" "+"姓名:"+em.getName()+" "+"工资:"+em.getSal()); } } } //员工类 class Employee { private String emNo; private String name; private float sal; // 构造方法 public Employee(String emNo, String name, float sal) { super(); this.emNo = emNo; this.name = name; this.sal = sal; } // 所有的getter和setter方法 public String getEmNo() { return emNo; } public void setEmNo(String emNo) { this.emNo = emNo; } public String getName() { return name; } public void setName(String name) { this.name = name; } public float getSal() { return sal; } public void setSal(float sal) { this.sal = sal; } } 运行示例:
{
Employee e=(Employee)al.get(i);
x=x+e.getSal();
}
System.out.println("平均工资:"+x/al.size());
Employee s=(Employee)al.get(0);
h=s.getSal();
l=s.getSal();
for(int i=0;i { Employee v=(Employee)al.get(i); if(v.getSal()>h) h=v.getSal(); if(v.getSal() l=v.getSal(); } System.out.println("最高工资:"+h); System.out.println("最低工资:"+l); } //显示所有员工的信息 public void showAll() { for(int i=0;i { Employee em=(Employee)al.get(i); System.out.println("第"+(i+1)+"个员工: "+"编号:"+em.getEmNo()+" "+"姓名:"+em.getName()+" "+"工资:"+em.getSal()); } } } //员工类 class Employee { private String emNo; private String name; private float sal; // 构造方法 public Employee(String emNo, String name, float sal) { super(); this.emNo = emNo; this.name = name; this.sal = sal; } // 所有的getter和setter方法 public String getEmNo() { return emNo; } public void setEmNo(String emNo) { this.emNo = emNo; } public String getName() { return name; } public void setName(String name) { this.name = name; } public float getSal() { return sal; } public void setSal(float sal) { this.sal = sal; } } 运行示例:
{
Employee v=(Employee)al.get(i);
if(v.getSal()>h)
h=v.getSal();
if(v.getSal() l=v.getSal(); } System.out.println("最高工资:"+h); System.out.println("最低工资:"+l); } //显示所有员工的信息 public void showAll() { for(int i=0;i { Employee em=(Employee)al.get(i); System.out.println("第"+(i+1)+"个员工: "+"编号:"+em.getEmNo()+" "+"姓名:"+em.getName()+" "+"工资:"+em.getSal()); } } } //员工类 class Employee { private String emNo; private String name; private float sal; // 构造方法 public Employee(String emNo, String name, float sal) { super(); this.emNo = emNo; this.name = name; this.sal = sal; } // 所有的getter和setter方法 public String getEmNo() { return emNo; } public void setEmNo(String emNo) { this.emNo = emNo; } public String getName() { return name; } public void setName(String name) { this.name = name; } public float getSal() { return sal; } public void setSal(float sal) { this.sal = sal; } } 运行示例:
l=v.getSal();
}
System.out.println("最高工资:"+h);
System.out.println("最低工资:"+l);
}
//显示所有员工的信息
public void showAll()
{
for(int i=0;i { Employee em=(Employee)al.get(i); System.out.println("第"+(i+1)+"个员工: "+"编号:"+em.getEmNo()+" "+"姓名:"+em.getName()+" "+"工资:"+em.getSal()); } } } //员工类 class Employee { private String emNo; private String name; private float sal; // 构造方法 public Employee(String emNo, String name, float sal) { super(); this.emNo = emNo; this.name = name; this.sal = sal; } // 所有的getter和setter方法 public String getEmNo() { return emNo; } public void setEmNo(String emNo) { this.emNo = emNo; } public String getName() { return name; } public void setName(String name) { this.name = name; } public float getSal() { return sal; } public void setSal(float sal) { this.sal = sal; } } 运行示例:
{
Employee em=(Employee)al.get(i);
System.out.println("第"+(i+1)+"个员工: "+"编号:"+em.getEmNo()+" "+"姓名:"+em.getName()+" "+"工资:"+em.getSal());
}
}
}
//员工类
class Employee {
private String emNo;
private String name;
private float sal;
// 构造方法
public Employee(String emNo, String name, float sal) {
super();
this.emNo = emNo;
this.name = name;
this.sal = sal;
}
// 所有的getter和setter方法
public String getEmNo() {
return emNo;
}
public void setEmNo(String emNo) {
this.emNo = emNo;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public float getSal() {
return sal;
}
public void setSal(float sal) {
this.sal = sal;
}
}
运行示例:
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~