编写一个描述职工基本情况的类属性包括姓名,职工号,性别,年龄,职务,部门,工资,奖金,方法包括输出个人信息,分配部门,设置职务,分配奖金,计算薪水, 要求实现职工号自动生成,不需要指定,按照创建的

package hrm3;
import java.lang.Math;
import java.util.Random;
import java.util.Scanner;

public class Employee {
	public String id;
	public String name;
	public int age;
	public String sex;
	public String job;
	public int work_time;
	public String Department;
	private int salary;
	private int award;
	public static int count=0; 
	public Employee()
	{
		count++;
		Scanner sc=new Scanner(System.in);
		System.out.println("请输入你的姓名:");
		name=sc.nextLine();
		System.out.println("请输入你的性别:");
		sex=sc.nextLine();
		System.out.println("请输入你的年龄:");
		age=sc.nextInt();
		System.out.println("请问你准备工作几个月:");
		work_time=sc.nextInt();
		setSalary();
		System.out.println("恭喜你已经成为我们公司的一员");
		assign_id();
		distribute_department();
		assign_job();
	}
	//输出个人信息
	public void ouput()
	{
		System.out.println("职工号:"+id);
		System.out.println("姓名:"+name);
		System.out.println("年龄"+age);
		System.out.println("性别:"+sex);
		System.out.println("职务:"+job);
		System.out.println("部门:"+Department);
		GiveOutAward();
		setSalary();
		System.out.println();
	}
	//生成职工号
	public void assign_id()
	{
		String base="0123456789";
		Random random=new Random();
		StringBuffer sb=new StringBuffer();
		for(int i=0;i<7;i++)
		{
			int num=random.nextInt(base.length());
			sb.append(base.charAt(num));
		}
		id=sb.toString();
		System.out.println("你的职工号为:"+id);
	}
	//分配部门
	public void distribute_department()
	{
		String[] str= {"研发部","市场部","销售部","生产部","财务部"};
		Random random=new Random();
		int num=random.nextInt(str.length);
		Department=str[num];
		System.out.println("你所在的部门为:"+Department);
	}
	//设置职务
	public void assign_job()
	{
		String[] ss= {"董事长","总经理","财务总监","会计","人事经理","销售经理","普通职工","高级职工","特级工程师"};
		Random random=new Random();
		int num=random.nextInt(ss.length);
		job=ss[num];
		System.out.println("你的职务为:"+job);
	}
	//分配奖金
	public void GiveOutAward()
	{
		int res=1000000;
		if(this.job.equals("董事长"))res=1000000;
		else if(this.job.equals("总经理"))res=500000;
		else if(this.job.equals("财务总监"))res=400000;
		else if(this.job.equals("人事经理"))res=400000;
		else if(this.job.equals("销售经理"))res=700000;
		else if(this.job.equals("特级工程师"))res=500000;
		else if(this.job.equals("会计"))res=200000;
		else if(this.job.equals("高级职工"))res=500000;
		else res=200000;
		award=res;
		System.out.println("你的奖金是"+award);
	}
	//计算薪水
	public void setSalary()
	{
		int res=10000;
		if(this.job.equals("董事长"))res=10000;
		else if(this.job.equals("总经理"))res=8000;
		else if(this.job.equals("财务总监"))res=7000;
		else if(this.job.equals("人事经理"))res=6000;
		else if(this.job.equals("销售经理"))res=7000;
		else if(this.job.equals("特级工程师"))res=6000;
		else if(this.job.equals("会计"))res=3000;
		else if(this.job.equals("高级职工"))res=5000;
		else res=3000;
		salary=res*work_time;
	}
	public static void main(String[] args) 
	{
		Scanner sc=new Scanner(System.in);
		int n;
		System.out.print("请输入要录入员工的人数:");
		n=sc.nextInt();
		Employee employee[]=new Employee[n];
		for(int i=0;i<n;i++)
		employee[i]=new Employee();
		System.out.print("员工人数:"+Employee.count);
		Random random=new Random();
		int i=random.nextInt(count);//随机显示某个员工的薪水
		employee[i].ouput();
	}
}
//随便输入的测试数据
请输入要录入员工的人数:3
请输入你的姓名:
光头强
请输入你的性别:
男
请输入你的年龄:
30
请问你准备工作几个月:
12
恭喜你已经成为我们公司的一员
你的职工号为:5912946
你所在的部门为:研发部
你的职务为:销售经理
请输入你的姓名:
李老板
请输入你的性别:
男
请输入你的年龄:
45
请问你准备工作几个月:
3
恭喜你已经成为我们公司的一员
你的职工号为:6631781
你所在的部门为:研发部
你的职务为:财务总监
请输入你的姓名:
熊大
请输入你的性别:
男
请输入你的年龄:
12
请问你准备工作几个月:
7
恭喜你已经成为我们公司的一员
你的职工号为:3332233
你所在的部门为:研发部
你的职务为:高级职工
员工人数:3职工号:3332233
姓名:熊大
年龄12
性别:男
职务:高级职工
部门:研发部
你的奖金是500000

  • 1
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值