java大作业编一个程序打印出公司某月各员工工资
- 格式:doc
- 大小:163.00 KB
- 文档页数:6
Java基础编程题1.某公司每⽉标准上班时间是160⼩时,每⼩时⼯资是30元。
如果上班时间超出了160⼩时,超出部分每⼩时按1.5倍⼯资发放。
请编写程序计算员⼯⽉⼯资。
1import java.util.Scanner;23public class Wag {4static int wag1(int a) {5int s = 0;6if (a > 0 && a <= 160) s = a * 30;7else if (a > 160)8 s = a * 30 + (a - 160) * 15;9else return 0;10return s;11 }1213public static void main(String[] args) {14 Scanner sc = new Scanner(System.in);15 System.out.println("程序员⼯作时间:");16int a = sc.nextInt();17int sum = wag1(a);18 System.out.println("程序员的⼯资:" + sum);19 }20 }测试结果!!不加班怎么来钱(⊙_⊙)!!2. 已知某年某⽉,请输出这个⽉共有多少天。
(if语句)/** 判断2009年是闰年还是平年。
*提⽰:*闰年的条件是符合下⾯⼆者之⼀:(1)年份能被4整除,但不能被100整除;(2)能被400整除。
**/1import java.util.Scanner;23public class Mouths {4static int day(int year, int mouth){5int s=0;6int[] a={31,28,31,30,31,30,31,31,30,31,30,31};7int[] b={31,29,31,30,31,30,31,31,30,31,30,31};8if((year%4==0&&year%100!=0)||(year%400==0)){9return s=b[mouth-1];10 }11else12return s=a[mouth-1];13 };14public static void main(String[] args){15 Scanner sc = new Scanner(System.in);16 System.out.println("年份:");17int year = sc.nextInt();18 System.out.println("⽉份:");19int mouth = sc.nextInt();20int days= day(year,mouth);21 System.out.println("这个⽉的天数:" + days);22 }23 }测试结果3. 根据学⽣成绩,打印学⽣考试等级。
java计算员工工资编程题计算员工工资的 Java 编程题可以有很多不同的变体,具体要求可能取决于实际情况和题目设定。
以下是一个简单的示例,展示了如何在 Java 中实现一个简单的员工工资计算程序。
请注意,这只是一个基本示例,实际场景中可能需要更多的细节和复杂性。
// 员工类class Employee {private String name;private double baseSalary;private double bonus;public Employee(String name, double baseSalary, double bonus) { = name;this.baseSalary = baseSalary;this.bonus = bonus;}public double calculateSalary() {return baseSalary + bonus;}// 其他可能需要的方法和属性}// 主程序public class PayrollSystem {public static void main(String[] args) {// 创建员工对象Employee employee1 = new Employee("John Doe", 50000, 2000);Employee employee2 = new Employee("Jane Smith", 60000, 2500);// 计算并打印工资System.out.println("Employee 1 Salary: $" + employee1.calculateSalary());System.out.println("Employee 2 Salary: $" + employee2.calculateSalary());}}在这个例子中,Employee 类有三个属性:name、baseSalary(基本工资)和 bonus(奖金)。
java实现⼯资管理简单程序本⽂为⼤家分享了java实现⼯资管理简单程序的具体代码,供⼤家参考,具体内容如下程序总体说明(ReadMe):总体分为四部分:管理程序(staffmanagment.java):在这⾥⾯使⽤了arraylist泛型来存放数据博主正在想办法把数据放进mysql,这样读取会更⽅便,⽽且数据不会消失当然(也可以把数据存⼊txt⽂件)import java.util.ArrayList;//员⼯管理public class staffmanagement {ArrayList al = null;//员⼯信息在这⾥⾯建⽴public staffmanagement(){al = new ArrayList();}//成员⽅法//添加新员⼯public void addstaff(staff staff){al.add(staff);}//根据⼯号查询员⼯的信息public void showInfo(String no){int flag = 0;for(int i=0; i<al.size(); i++){staff staff= (staff)al.get(i);if(staff.getNo().equals(no)){flag = 1;System.out.println("员⼯"+(i+1)+"的信息是:");System.out.print("姓名:"+staff.getName());System.out.print(" 性别:"+staff.getSex());System.out.print(" 年龄:"+staff.getAge());System.out.print(" ⼯号:"+staff.getNo());System.out.print(" 薪资:"+staff.getSalary());System.out.print(" ⼯作:");if(staff.getWork() == 1) System.out.println("common staff");else if(staff.getWork() == 2) System.out.println("common manager");else if(staff.getWork() == 3) System.out.println("head manager");System.out.println(staff);}}if(flag == 0)System.out.println("该⼯号不存在");}//显⽰所有员⼯信息public void showAllInfo(){for(int i=0; i<al.size(); i++){staff staff= (staff)al.get(i);System.out.println("staff"+(i+1)+"的信息是:");System.out.print("姓名:"+staff.getName());System.out.print(" 性别:"+staff.getSex());System.out.print(" 年龄:"+staff.getAge());System.out.print(" ⼯号:"+staff.getNo());System.out.print(" 薪资:"+staff.getSalary());System.out.print(" ⼯作:");if(staff.getWork() == 1) System.out.println("common staff");else if(staff.getWork() == 2) System.out.println("common manager");else if(staff.getWork() == 3) System.out.println("head manager");System.out.println(staff);}}//修改员⼯的薪⽔public void modifySal(String no, double sal) //员⼯⼯号最新的薪资{int flag = 0;for(int i=0; i<al.size(); i++){staff staff= (staff)al.get(i);if(staff.getNo().equals(no)){flag = 1;staff.setSalary(sal);}}if(flag == 0)System.out.println("找不到所查⼯号");}//根据⼯号删除该员⼯的信息public void deleteInfo(String no){int flag = 0;for(int i=0; i<al.size(); i++){staff staff= (staff)al.get(i);if(staff.getNo().equals(no)){flag = 1;al.remove(i);}}if(flag == 0)System.out.println("找不到所查⼯号");}//统计当前公司的三个⽔平⼯资线public void calSalary() {if (al.isEmpty()) {System.out.println("the stafflist is empty,please input the staff infomation"); System.out.println("please input the No 1 to add the staffinfo");} else {double totalSal = 0;double minSal = ((staff) al.get(0)).getSalary();double maxSal = ((staff) al.get(0)).getSalary();for (int i = 0; i < al.size(); i++) {staff staff = (staff) al.get(i);totalSal += staff.getSalary();if (minSal > staff.getSalary()) {minSal = staff.getSalary();}if (maxSal < staff.getSalary()) {maxSal = staff.getSalary();}}System.out.println(al.size() + "个⼈的平均薪资为:" + totalSal / al.size()); System.out.println(al.size() + "个⼈的最低薪资为:" + minSal);System.out.println(al.size() + "个⼈的最⾼薪资为:" + maxSal);}}}界⾯模块(SalarySystem.java)对不同员⼯的⼯资最低进⾏了限制,毕竟法律规定了不能给太低年龄也是(⾄少得成年吧——你懂的)职位还可以安排更多import java.io.BufferedReader;import java.io.IOException;import java.io.InputStreamReader;import java.util.Scanner;/** @antuor:jeffw* 员⼯界⾯为博主清风追梦的写法* 清风⼤⼤的blogs:/qingfengzhuimeng/p/6509965.html* io输⼊输出* 在员⼯的类别上加⼊员⼯的职业区分别建⽴不同的类* 程序使⽤英语+中⽂⽅式= =顺便练习英语*/public class SalarySystem {public static void main(String[] args) throws IOException //使⽤bufferreader读取更加的安全,当读取不到的返回错误抛出 {staffmanagement sys = new staffmanagement();InputStreamReader isr = new InputStreamReader(System.in);//输⼊流为系统,也可以从⽂本读取,⼀次读取⼀个字符 BufferedReader br = new BufferedReader(isr);//读取,对输⼊流的封装,可以读取⼀⾏,⼀个字符或者是⼀个数字//这⾥以isr读取到的传给brwhile(true){//简易菜单System.out.println("简单管理菜单" );System.out.println("---------------------------------------");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.println("9.清屏");System.out.println("0.退出");System.out.println("---------------------------------------");System.out.println("请选择序号:");String no = br.readLine();if(no.equals("1")) {System.out.println("添加新员⼯:");System.out.println("请输⼊姓名:");String name = br.readLine();System.out.println("请输⼊性别(男or⼥):");String sex = br.readLine();System.out.println("请输⼊⼯作:");System.out.println("⽬前共有三种职位:\n" +"mon_staff\n" +"mon_manager\n" +"3.head_manager");System.out.println("please input the work id:");int work = Integer.parseInt(br.readLine());System.out.println("请输⼊年龄:");Scanner sc = new Scanner(System.in);int age = sc.nextInt();if( age < 18 ){System.out.println("the age is too small,please input again");sc = new Scanner(System.in);age = sc.nextInt();}System.out.println("请输⼊⼯号:");String staffNo = br.readLine();System.out.println("请输⼊⼯资:");double salary = Double.parseDouble(br.readLine());if( work == 1 ) {while (salary < 2000) {System.out.println("the common staff's salary is too low");System.out.println("请重新输⼊");salary = Double.parseDouble(br.readLine());}}else if( work == 2 ) {while (salary < 5000) {System.out.println("the manager's salary is too low");System.out.println("请重新输⼊");salary = Double.parseDouble(br.readLine());}}else if( work == 3 ) {while (salary < 8000) {System.out.println("the head manager's salary is too low");System.out.println("请重新输⼊");salary = Double.parseDouble(br.readLine());}}staff staff = null;if (work == 1) {staff = new staff(name, sex, age, staffNo, salary, work);} else if(work == 2){staff = new manager(name, sex, age, staffNo, salary, work);}else if(work == 3 ) {staff = new manager(name, sex, age, staffNo, salary, work);}sys.addstaff(staff);}else if(no.equals("2")){System.out.println("请输⼊员⼯号:");String staffNo = br.readLine();sys.showInfo(staffNo);}else if(no.equals("3")){System.out.println("显⽰所有员⼯信息:");sys.showAllInfo();}else if(no.equals("4")){System.out.println("修改员⼯的薪⽔:");System.out.println("输⼊员⼯⼯号:");String staffNo = br.readLine();//接收输⼊的⼯号System.out.println("修改后的员⼯⼯资:");String sal = br.readLine();double salary = Double.parseDouble(sal);sys.modifySal(staffNo, salary);}else if(no.equals("5")){System.out.println("根据⼯号删除该员⼯的信息:");System.out.println("输⼊员⼯⼯号:");String staffNo = br.readLine();//接收输⼊的⼯号sys.deleteInfo(staffNo);}else if(no.equals("6")){System.out.println("统计员⼯的平均⼯资、最⾼⼯资和最低⼯资:");sys.calSalary();}else if(no.equals("7")) {System.out.println("查看具体⼯作名称:\n" +"序号1为common staff\n" +"序号2为conmmon manager\n" +"序号3为head manger");}else if(no.equals("8")) {System.out.println("最低⼯资说明:\n" +"mon staff 最低⼯资为2000\n" +"2.conmmon manager 最低⼯资为5000\n" +"3.head manager 最低⼯资为8000\n");}else if(no.equals("9")){int i=0;while( i < 80) {System.out.println("********");i++;}//java因为ide的原因没有提供内置类似c++的⽅法,所以只能简陋的使⽤***来清屏了= = System.out.println("如果觉得看着⿇烦的话,可以在console⾥⾯⿏标右击->clear");}else if(no.equals("0")){System.exit(0);}else{System.out.println("请输⼊正确的序号");}}}}普通职位模块(staff.java)所有的员⼯模块通过此模块进⾏扩展//普通员⼯类public class staff{private String name;private String sex;private int age;private String no;private double salary;private int work;public staff(){}public staff(String name, String sex, int age, String no, double salary,int work){ = name;this.sex = sex;this.age = age;this.no = no;this.salary = salary;this.work = work;}@Overridepublic String toString() {// return "this is a common staff\n"// +"name:"+name+"\n"// +"sex :"+sex+"\n"// +"age :"+age+"\n"// +"no :"+no+"\n"// +"salary :"+salary+"\n"// +"work :"+work+"\n";return getWork()+" the common staff is working and the salary is "+getSalary()+"\n" +"his/her workid is 1 and he/she needs handle with the company's common situations"; }public String getName() {return name;}public void setName(String name) { = name;}public String getSex() {return sex;}public void setSex(String sex) {this.sex = sex;}public int getAge() {return age;}public void setAge(int age) {this.age = age;}public String getNo() {return no;}public void setNo(String no) {this.no = no;}public double getSalary() {return salary;}public void setSalary(double salary) {this.salary = salary;}public void setWork(int work){this.work = work;}public int getWork(){return work;}}扩展职位模块mon managerpublic class manager extends staff{public manager(String name, String sex, int age, String no, double salary, int work) {setName(name);setSalary(salary);setAge(age);setNo(no);setSex(sex);setWork(work);}public manager(){System.out.println("this is a manager");}@Overridepublic String toString() {return "the manager is working and the salary is "+getSalary()+"\n" +"his workid is 3 and he needs handle with the company's emergency situations";}}2.head managerpublic class headmanager extends manager{public headmanager(String name, String sex, int age, String no, double salary, int work) {setName(name);setSalary(salary);setAge(age);setNo(no);setSex(sex);setWork(work);}public headmanager(){System.out.println("this is a headmanager");System.out.println("his workid is 3 " +"and he needs handle with " +"the company's emergency situations");}@Overridepublic String toString() {return "the headmanager is working and the salary is "+getSalary()+getSalary()+"\n" +"his/her workid is 2 and he/she needs hanle whih the compant's main development"; }}运⾏展⽰2018.12.15更新:现在还没有想到怎么⽤数据库连接,不过新学习了file⽂件操作模式,现在把这种⽅式加⼊到员⼯管理⾥⾯:以下是增加内容:else if(no.equals("10")) {System.out.println("正在读取中,请稍候...");File file = new File("1.txt");Scanner input = new Scanner(file);while(input.hasNext()){String name = input.nextLine();String sex = input.nextLine();int work = input.nextInt();int age =input.nextInt();input.nextLine();String staffNo = input.nextLine();double salary = input.nextDouble();staff staff = null;if (work == 1) {staff = new staff(name, sex, age, staffNo, salary, work);} else if(work == 2){staff = new manager(name, sex, age, staffNo, salary, work);}else if(work == 3 ) {staff = new manager(name, sex, age, staffNo, salary, work);}else{System.out.println("不存在此职业");}sys.addstaff(staff);System.out.println("导⼊成功");}接下来的想法是把重复的员⼯去除,想先通过提醒使⽤者导⼊员⼯后,删除原有员⼯⽂件,然后在使⽤者退出前提⽰导⼊员⼯名单进⾏解决可能出现的员⼯重复问题以上就是本⽂的全部内容,希望对⼤家的学习有所帮助,也希望⼤家多多⽀持。
假定要为某个公司编写雇员工资支付程序。
这个公司有各种类型的雇员(Employee),不同类型雇员按不同的方式支付工资:(1)经理〔Manager〕——每个月获得一份固定的工资(2)销售人员〔Salesman〕——在根本工资的根底上每月还有销售提成(3)一般工人〔Worker〕——那么按他每月工作的天数计算工资。
试用类的继承与相关机制描述这些功能需求,并编写一个Java Application程序,演示这些类的用法。
〔提示:应设计一个雇员类〔Employee〕描述所有雇员的共同特性,这个类应该提供一个计算工资的抽象方法computeSalary( ),使得可以通过这个类计算所有雇员的工资。
经理、销售人员、一般工人对应的类都应该继承这个类,并重新定义计算工资的方法,并给出它的具体实现。
〕abstract class Employee{private String name;public Employee(String name){=name;}public String getName(){return name;}public abstract double computeSalary();}class Manager extends Employee{double monthSalary;public Manager(String name,double monthSalary){super(name);this.monthSalary=monthSalary;}public double computeSalary(){return monthSalary;}}class Salesman extends Employee{double baseSalary;int quantity;double commision;public Salesman(String name,double baseSalary,int quantity,double commision){ super(name);this.baseSalary=baseSalary;this.quantity=quantity;this mision=commision;}public double computeSalary(){return baseSalary+quantity*commision;}}class Worker extends Employee{int days;double dailySalary;public Worker(String name,int days,double dailySalary){super(name);this.days=days;this.dailySalary=dailySalary;}public double computeSalary(){return days*dailySalary;}}public class EmployeeDemo{public static void main(String args[]){Manager m=new Manager("张三",10000);Salesman s=new Salesman("李四",2000,50,80);Worker w=new Worker("王五",28,80);System.out.println("经理"+m.getName()+"的工资为:"+m puteSalary());System.out.println("销售人员"+s.getName()+"的工资为:"+s puteSalary());System.out.println("工人"+w.getName()+"的工资为:"+w puteSalary());}}。
员工工资管理是一个常见的管理系统,下面是一个简单的Java 题员工工资管理的示例:```javaimport java.util.ArrayList;import java.util.List;class Employee {private String name;private double salary;public Employee(String name, double salary) { = name;this.salary = salary;}// Getters and setterspublic String getName() {return name;}public void setName(String name) { = name;}public double getSalary() {return salary;}public void setSalary(double salary) {this.salary = salary;}}class SalaryManagementSystem {private List<Employee> employees;public SalaryManagementSystem() {this.employees = new ArrayList<>();}public void addEmployee(Employee employee) {employees.add(employee);}public void removeEmployee(Employee employee) {employees.remove(employee);}public double calculateTotalSalary() {double totalSalary = 0;for (Employee employee : employees) {totalSalary += employee.getSalary();}return totalSalary;}public void displayEmployees() {for (Employee employee : employees) {System.out.println("Name: " + employee.getName() + ", Salary: " + employee.getSalary());}}}public class Main {public static void main(String[] args) {SalaryManagementSystem salaryManagementSystem = new SalaryManagementSystem();// 添加员工Employee employee1 = new Employee("John", 5000);Employee employee2 = new Employee("Alice", 6000);salaryManagementSystem.addEmployee(employee1);salaryManagementSystem.addEmployee(employee2);// 显示所有员工salaryManagementSystem.displayEmployees();// 计算总工资double totalSalary = salaryManagementSystem.calculateTotalSalary(); System.out.println("Total Salary: " + totalSalary);// 移除员工salaryManagementSystem.removeEmployee(employee2);// 显示更新后的员工列表salaryManagementSystem.displayEmployees();}}```以上代码示例中,`Employee` 类表示员工对象,包含姓名和工资属性。
经理与员工工资案例java一、背景介绍在企业中,经理和员工的薪资是一项非常重要的问题。
如果薪资分配不公,就会影响到员工的积极性和团队合作精神,进而影响到企业的发展。
因此,对于经理和员工的薪资制度设计和实施非常重要。
二、案例描述假设某公司有10个员工,其中有5个普通员工、3个高级员工和2个经理。
公司规定普通员工每月底薪为3000元,高级员工每月底薪为5000元,经理每月底薪为8000元。
此外,公司还规定了以下奖金制度:1. 普通员工:按照月度销售额给予2%的销售提成。
2. 高级员工:按照月度销售额给予5%的销售提成。
3. 经理:按照公司整体利润给予10%的年终奖。
现在需要编写一个Java程序来计算每个员工的实际收入,并输出结果。
三、解决方案1. 设计Employee类首先需要设计一个Employee类来表示每个员工。
该类包含以下属性:- name:姓名- position:职位(普通员工、高级员工或经理)- baseSalary:底薪- sales:月度销售额- profit:公司整体利润该类还包含以下方法:- 构造方法:根据职位设置底薪。
- getSalary()方法:计算实际收入,包括底薪和奖金。
2. 编写程序在主程序中,创建10个Employee对象,分别表示10个员工。
根据每个员工的职位、销售额和公司利润,计算出每个员工的实际收入,并输出结果。
四、代码实现1. Employee类```public class Employee {private String name;private String position;private double baseSalary;private double sales;private double profit;public Employee(String name, String position) { = name;this.position = position;if (position.equals("普通员工")) {this.baseSalary = 3000;} else if (position.equals("高级员工")) {this.baseSalary = 5000;} else if (position.equals("经理")) {this.baseSalary = 8000;}}public void setSales(double sales) {this.sales = sales;}public void setProfit(double profit) {this.profit = profit;}public double getSalary() {double salary = baseSalary;if (position.equals("普通员工")) {salary += sales * 0.02; // 计算销售提成} else if (position.equals("高级员工")) {salary += sales * 0.05; // 计算销售提成} else if (position.equals("经理")) {salary += profit * 0.1; // 计算年终奖}return salary;}public String toString() {return "姓名:" + name + ",职位:" + position + ",实际收入:" + getSalary();}}```2. 主程序```public class Main {public static void main(String[] args) {Employee[] employees = new Employee[10];employees[0] = new Employee("张三", "普通员工");employees[1] = new Employee("李四", "普通员工");employees[2] = new Employee("王五", "普通员工");employees[3] = new Employee("赵六", "普通员工");employees[4] = new Employee("钱七", "普通员工");employees[5] = new Employee("孙八", "高级员工");employees[6] = new Employee("周九", "高级员工");employees[7] = new Employee("吴十", "高级员工");employees[8] = new Employee("郑一", "经理");employees[9] = new Employee("陈二", "经理");for (int i = 0; i < 10; i++) {if (employees[i].getPosition().equals("普通员工") || employees[i].getPosition().equals("高级员工")) {double sales = Math.random() * 100000; // 随机生成销售额employees[i].setSales(sales);} else if (employees[i].getPosition().equals("经理")) {double profit = Math.random() * 1000000; // 随机生成公司利润employees[i].setProfit(profit);}System.out.println(employees[i]);}}}```五、运行结果运行程序,输出每个员工的实际收入:```姓名:张三,职位:普通员工,实际收入:3600.0 姓名:李四,职位:普通员工,实际收入:3900.0 姓名:王五,职位:普通员工,实际收入:3200.0 姓名:赵六,职位:普通员工,实际收入:3700.0 姓名:钱七,职位:普通员工,实际收入:3800.0 姓名:孙八,职位:高级员工,实际收入:7505.8 姓名:周九,职位:高级员工,实际收入:8537.9 姓名:吴十,职位:高级员工,实际收入:7275.7 姓名:郑一,职位:经理,实际收入:80800.8 姓名:陈二,职位:经理,实际收入:240873.3 ```六、总结与思考通过本案例,可以看出Java语言的面向对象特性在实际开发中的应用。
java编写计算职工工资的方法一、评估与概述在现代社会中,计算职工工资是企业管理中至关重要的一个方面。
通过编写Java程序来计算职工工资,不仅可以提高工作效率,还可以减少出错的可能性,确保工资的准确性和公正性。
本文将通过深度和广度的方式来探讨如何使用Java编写计算职工工资的方法,以便读者能全面、深刻地理解这一主题。
二、从简到繁,由浅入深的探讨1. 计算基本工资计算职工的基本工资是计算职工工资的第一步。
基本工资通常是根据工作岗位和工作时间来确定的。
在Java程序中,可以通过输入工作岗位和工作时间,然后根据预先设定的工资标准来计算基本工资。
这部分的代码可以包括输入输出模块、条件判断和变量赋值等基本操作。
2. 添加绩效奖金在计算基本工资的基础上,绩效奖金是职工工资中常见的一部分。
在编写Java程序时,需要设置绩效考核的标准,并根据考核结果来确定是否添加绩效奖金。
这部分的代码可以包括函数调用和逻辑运算等方面。
3. 加入福利和补贴福利和补贴也是职工工资中不可忽视的部分。
在Java程序中,需要将各种福利和补贴项目进行分类和计算,并将其加入到职工工资中。
这部分的代码可以包括循环结构和数组操作等内容。
4. 扣除法定税款还需扣除职工的法定税款。
在Java程序中,可以根据税法对应的规定来计算应扣除的税款,并将其从职工工资中扣除。
这部分的代码可以包括异常处理和文件操作等方面。
通过以上步骤的深入探讨,读者能够逐步了解如何使用Java来编写计算职工工资的方法,从而达到更深入的理解。
三、个人观点和理解在我看来,使用Java编写计算职工工资的方法不仅可以提高工作效率,还可以减少人为错误的可能性。
由于Java具有跨评台性和良好的可维护性,编写的程序在不同的环境中都可以运行,并且容易进行修改和更新。
我认为掌握Java编程技能对企业管理人员来说是非常重要的。
结语在本文中,我们通过从简到繁、由浅入深的方式探讨了如何使用Java编写计算职工工资的方法。
得分:课程设计报告企业工资管理系统姓名张栋梁班级学号13软件1 1310321129课程名称数据库原理及应用指导教师 ____________ 熊英2015年6月27日1、需求分析1.1 功能需求1.1.1 功能划分(1) 、员工信息表;及时反映员工的基本信息(2) 、员工津贴表,反映员工津贴(3) 、员工基本工资表1.1.2 功能描述(1) 、基本工资的设定(2) 、津贴的设定(3) 、计算出月工资(4) 、录入员工工资信息(5 )、添加员工工资信息(6)、更改员工工资信息1.2 性能需求此工资管理系统对工资数据精度的计算能在默认情况之下精确到小数点后3位小数,即是精确到分的计算。
但在用户使用过程中,能自行根据实际情况进行小数计算精度的设定,最大能允许保留小数点后5 位的精度。
在时间特性上,当用户发出命令请求时的服务器的响应时间、对数据更新处理、工资数据的查询检索等上,同样要求系统响应时间不会超过0.5 秒时间。
系统支持多种操作系统的运行环境,多不同操作系统,不同文件格式的磁盘上的数据均能实现信息的互通,及共享。
当服务器移植到其他的系统平台,如:Linux 平台下时,同样能和其他的系统进行数据存取同步,不会出现系统之间互不兼容的情况,系统支持多系统之间的互连互通,系统有巨大的强健性。
本课程设计是用Java 语言编写,mysql 数据库。
1.3 数据流图根据工资管理要求及用户需求调查分析,得到以下数据流图图1.1 第一层数据流图图1.2职工信息的载入图1.4考勤的信息载入2.总体设计2.1数据库概念设计有了数据流图,用E-R图来说明工资信息管理系统的数据库概念模式,如图姓名基本工资2.2功能模块3 •系统详细设计3.1数据库逻辑设计将以上E-R转换成如下关系模式员工(职工号,姓名,密码)工资(职工号,姓名,基本工资,)津贴(职工号,姓名,奖金)其中,标有下划线的字段表示为该数据表的主码,即主关键字。
Java工资管理系统代码简介工资管理是企业人力资源管理中重要的一环,可以通过一个可靠的工资管理系统来方便地计算、调整、记录和管理员工工资信息。
本文将介绍一个基于Java语言开发的简单而实用的工资管理系统代码。
功能特点该工资管理系统代码具有以下功能特点:1.员工管理:可以添加、删除、修改和查询员工信息。
2.工资计算:可以根据员工的基本工资、绩效考核等因素来计算实际工资。
3.工资调整:可以根据业务需要进行工资调整,并记录调整日志。
4.工资报表:可以生成月度、季度或年度的工资报表,用于管理和分析工资情况。
系统框架该工资管理系统代码基于Java语言开发,采用MVC(Model-View-Controller)架构,方便代码的维护和扩展。
模型层(Model)模型层负责处理数据相关的逻辑,包括员工信息的增删改查、工资的计算和调整等。
视图层(View)视图层负责与用户的交互,展示员工信息、工资报表等内容,并接收用户的操作。
控制层(Controller)控制层负责处理用户操作的逻辑,根据用户的请求调用模型层的方法,并将结果返回给视图层。
代码示例下面是部分Java代码示例,展示了工资管理系统的主要功能:```java // 员工类 public class Employee { private int id; private String name; private double baseSalary; // 其他属性和方法省略// 获取员工实际工资public double getActualSalary() {// 根据基本工资、绩效考核等因素来计算工资// 省略具体实现}}// 工资管理类 public class SalaryManager { // 员工列表 private List employees; // 其他属性和方法省略// 添加员工public void addEmployee(Employee employee) {// 省略具体实现}// 删除员工public void deleteEmployee(int id) {// 省略具体实现}// 修改员工信息public void updateEmployee(Employee employee) {// 省略具体实现}// 查询员工信息public Employee findEmployee(int id) {// 省略具体实现}// 计算员工工资public double calculateSalary(Employee employee) {// 省略具体实现}// 调整员工工资public void adjustSalary(Employee employee, double newSalary) {// 省略具体实现}// 生成工资报表public void generateSalaryReport() {// 省略具体实现}}// 主程序 public class Main { public static void main(String[] args) { // 创建工资管理对象 SalaryManager salaryManager = new SalaryManager();// 添加员工Employee employee1 = new Employee(1, \。
java计算工资的计算例题在Java中,计算工资是一个常见的问题。
本文将以一个计算工资的例题为例,详细介绍如何使用Java编写计算工资的程序。
假设有一个公司,员工的薪水计算方式如下:- 基本工资:每月2000元;- 加班工资:每小时30元;- 奖金:根据绩效来确定,分为A、B、C、D四级,分别对应基本工资的30%、20%、10%、无奖金;- 五险一金:工资的10%。
现在,我们需要编写一个Java程序来计算员工的工资,具体要求如下:1. 输入员工的加班小时数和绩效等级,并通过计算返回员工的实际工资;2. 实现一个方法,该方法接受两个参数,分别为加班小时数和绩效等级,返回实际工资;3. 使用if-else语句根据绩效等级计算奖金;4. 计算实际工资时,先根据加班小时数计算加班工资,再加上基本工资和奖金,最后再减去五险一金。
下面就让我们来一步步完成这个计算工资的程序。
首先,我们需要创建一个名为CalculateSalary的Java类。
在该类中,我们声明一个名为calculateActualSalary的方法,代码如下:```javapublic class CalculateSalary {public static double calculateActualSalary(int overtimeHours, String performance) {double basicSalary = 2000; // 基本工资固定为2000元double overtimePay = overtimeHours * 30; // 加班工资每小时30元double bonus;if (performance.equals("A")) {bonus = basicSalary * 0.3; // 绩效A对应奖金为基本工资的30%} else if (performance.equals("B")) {bonus = basicSalary * 0.2; // 绩效B对应奖金为基本工资的20%} else if (performance.equals("C")) {bonus = basicSalary * 0.1; // 绩效C对应奖金为基本工资的10%} else {bonus = 0; // 绩效D对应无奖金}double insurance = basicSalary * 0.1; // 五险一金为工资的10%double actualSalary = basicSalary + overtimePay + bonus - insurance; // 计算实际工资return actualSalary;}}```在上述代码中,我们首先设置基本工资和加班工资的变量,并声明一个bonus变量用于存储奖金的值。
姓名:王镱澍Java大作业一、题目白浪公司的雇员根据参数月份来确定工资,如果该月员工过生日,则公司会额外奖励100元。
雇员分为以下若干类:SalariedEmployee:拿固定工资的员工。
HourlyEmployee:按小时拿工资的员工。
SalesEmployee:销售人员,工资由月销售额和提成率决定。
BasePlusSalesEmployee:有固定底薪的销售人员,工资由底薪加上销售提成。
公司会给SalaryEmployee每月另外发放2000元加班费,给 BasePlusSalesEmployee发放1000元加班费。
编一个java程序创建上述若干类,并实现确定月份以及该月不同员工的工作情况后打印出该公司该月各员工工资,公司总的工资支出情况。
二、程序功能说明编一个java程序创建上述若干类,并实现确定该月不同员工的工作情况以及输入月份后打印出该公司该月各员工工资,公司总的工资支出情况。
三、类、属性、方法说明程序中已给出详细解释在此只作简要说明:Employee:这是所有员工总的父类。
属性:员工的姓名和生日月份。
方法:getSalary(int month) 根据参数月份来确定工资,如果该月员工过生日,则公司会额外奖励100元。
SalariedEmployee:Employee的子类,拿固定工资的员工。
属性:月薪。
方法:每月工作超出160小时的部分按照1.5倍工资发放。
HourlyEmployee:Employee的子类,按小时拿工资的员工。
属性:每小时的工资、每月工作的小时数。
SalesEmployee:Employee的子类,销售人员。
属性:月销售额、提成率。
方法:工资由月销售额和提成率决定。
BasePlusSalesEmployee:SalesEmployee的子类,有固定底薪的销售人员。
属性:底薪。
方法:工资由底薪加上销售提成部分。
四、程序代码import java.util.*;class MyException extends Exception{MyException(){} //创建自己的异常定义}public class EmployeeTest{//月份输入函数。
static int scanf() throws MyException{Scanner in=new Scanner(System.in);int s=in.nextInt();if(s<1|s>12) { throw new MyException(); } //月份不正确时抛出定义的异常。
else return s;}//主函数入口。
public static void main(String[] args){Employee ep[] = new Employee[4];ep[0] = new SalariedEmployee("魏威",2,5000);ep[1] = new HourlyEmployee("段利峰",8,80,242);ep[2] = new SalesEmployee("林龙",11,300000,0.1);ep[3] = new BasedPlusSalesEmployee("华溪",1,100000,0.15,1500);System.out.println("请输入月份:");int month=1;int data=1;while(data==1){try {month=scanf();data=0;}catch(MyException e) { System.out.println("月份是1-12月请输入正确月份"); }}System.out.println("白浪集团"+month+"月工资表:");for(int i=0;i<ep.length;i++){System.out.println(ep[i].getName()+": "+ep[i].getSalary(month));}//统计加班费int result = 0;for(int i=0;i<ep.length;i++) {result += ep[i].getAddtionalSalary();}System.out.println("加班费: "+result);//统计本月给出员工的总工资int salary=0;for(int i=0;i<ep.length;i++){ salary +=ep[i].getSalary(month)+ep[i].getAddtionalSalary();}System.out.println("本月给出员工的总工资: "+salary);}//定义加班费接口interface AddtionalSalary{int getAddtionalSalary();}/***这是所有员工总的父类。
*属性:员工的姓名和生日月份。
*方法:getSalary(),getName(),getAddtionalSalary()*/class Employee implements AddtionalSalary{private String name;//员工姓名private int birth;//员工生日月份public Employee(String name,int birth){ = name;this.birth = birth;}/***方法说明:根据参数月份来确定工资,如果该月员工过生日,则公司会额外奖 *励100元。
*/public int getSalary(int month){int result = 0; if(month==birth)result = 100; return result;}public String getName() {return name;} //方法说明:获取员工姓名。
/***方法说明: 公司会给SalaryEmployee每月另外发放2000元加班费,给*BasePlusSalesEmployee发放1000元加班费*/public int getAddtionalSalary() {return 0;}}/***Employee的子类,拿固定工资的SalariedEmployee员工。
*属性:月薪*方法:getSalary(),getAddtionalSalary().*/class SalariedEmployee extends Employee{private int salaryPerMonth;public SalariedEmployee(String name,int birth,int salaryPerMonth)super(name,birth);this.salaryPerMonth = salaryPerMonth;}//按小时拿工资的员工,每月工作超出160小时的部分按照1.5倍工资发放.public int getSalary(int month){return this.salaryPerMonth + super.getSalary(month)+this.getAddtionalSalary();}public int getAddtionalSalary() {return 2000;}}/***Employee的子类,按小时拿工资的员工。
*属性:每小时的工资、每月工作的小时数。
*方法:getSalary()*/class HourlyEmployee extends Employee{private int salaryPerHour;private int hoursPerMonth;public HourlyEmployee(String name,int birth,int salaryPerHour,int hoursPerMonth){super(name,birth);this.salaryPerHour = salaryPerHour;this.hoursPerMonth = hoursPerMonth;}public int getSalary(int month){int result = 0;if(this.hoursPerMonth<=160){result = hoursPerMonth*salaryPerHour;}else{result = 160*salaryPerHour +(int)((hoursPerMonth-160)*1.5*salaryPerHour);}return result+super.getSalary(month);}}/***Employee的子类,销售人员.*属性: 月销售额、提成率.*方法: getSalary().*/class SalesEmployee extends Employee{private int sales;private double rate;public SalesEmployee(String name,int birth,int sales,double rate){super(name,birth);this.sales = sales;this.rate = rate;}//方法说明:工资由月销售额和提成率决定.public int getSalary(int month){return (int)(sales*rate)+super.getSalary(month);}}/***SalesEmployee的子类,有固定底薪的销售人员.*属性: 底薪.*方法: getSalary(),getAddtionalSalary().*/class BasedPlusSalesEmployee extends SalesEmployee{private int basedSalary;public BasedPlusSalesEmployee(String name,int birth,int sales,double rate,int basedSalary){super(name,birth,sales,rate);this.basedSalary = basedSalary;}public int getSalary(int month)// 工资由底薪加上销售提成部分{return this.basedSalary+super.getSalary(month) +this.getAddtionalSalary();}public int getAddtionalSalary(){return 1000;}}五、运行结果在C:\Program Files\Java\text目录下产生的类文件:六、结果说明当输入正确的1-12月月份后程序就根据开始定义的员工生日情况给本月过生的员工增加100工资例如输入月份为2时魏威工资7000+100=7100,同理分析列出的其他员工的工资情况和公司支出情况,与笔算结果相符,可见程序实现了题目的功能。