java工资生成代码 用java编写员工工资
用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编写程序
代码一
public double earnings()
{double a=50000.456;
return a;
}
代码二
public double earnings()
{double b=2000;
return 12*b;}
代码三
public double earnings()
{double c=500;
return 52*c;}
代码四
我也正在思考中
使用java编写程序实现输入员工工资,获得员工的平均工资,要求使用象数组类型的
import java.util.Scanner;
public class Two {
public static void main(String[] args) {
Scanner qffg = new Scanner(System.in);
System.out.println("输入与员工人数");
int np = qffg.nextInt();
int[] arr = new int[np];
int sum = 0;
for(int a=0;aarr.length;a++) {
System.out.println("输入第"+(a+1)+"个员工的工资");
arr[a] = qffg.nextInt();
sum += arr[a];
}
System.out.println("员工平均工资为:"+sum/np);
}
}
java 编程 计算工人工资,
JAVA计算工人工资,参考例子如下:
import java.util.Scanner;
public class Demo00 {
//定义一个三维数组,用于记录每个部门、分支、绩效工资
private static final float[][][] SALARY_OF_PER_HOUR = {
{{10.75f,12.50f,14.50f},{11.75f,14.50f,17.50f}},
{{13.00f,16.00f,18.50f},{15.00f,18.50f,22.00f}},
{{16.75f,18.50f,20.50f},{19.25f,25.00f,30.00f}}
};
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
//输入姓名
System.out.println("请输入姓名:");
String name = sc.nextLine();
//输入部门并验证
System.out.println("请输入部门: A,B,C");
char dept = sc.nextLine().charAt(0);
if(dept'A'||dept'C')
{
System.out.println("输入有误,系统将退出");
System.exit(0);
}
//输入分支机构并验证
System.out.println("请输入分支机构: 1,2");
char div = sc.nextLine().charAt(0);
if(div'1'||div'2')
{
System.out.println("输入有误,系统将退出");
System.exit(0);
}
//输入薪绩表并验证
System.out.println("请输入薪绩表: a,b,c");
char sal = sc.nextLine().charAt(0);
if(sal'a'||sal'c')
{
System.out.println("输入有误,系统将退出");
System.exit(0);
}
//输入小时数
System.out.println("请输入本周工作时间(整小时数):");
int hours = sc.nextInt();
float salary = 0;
//每个小时的薪水
float salaryPerHour = SALARY_OF_PER_HOUR[dept-'A'][div-'1'][sal-'a'];
//分别计算40小时内和超过40小时的薪水
if(hours=40)
{
salary += salaryPerHour*hours;
}
else
{
salary += salaryPerHour*hours+(hours-40)*1.5*salaryPerHour;
}
//输出结果
System.out.println("姓名:\t"+name+"\n部门:\t"+dept+"\n分支机构:\t"+div
+"\n薪绩表:\t"+sal+"\n工作时间:\t"+hours+"\n薪水:\t"+salary);
}
}
//Best wishes!
java计算工资
person类:
public abstract class Person {
public double pay; // 总工资
public int hour; // 课时
public double countPay(int hour) {
return pay;
}
}
助教类:
public class Assistant extends Person {
public final double BASE_PAY = 800; // 基本工资
public final double HOUR_PAY = 25; // 每课时的费用
public double countPay(int hour) {
pay = BASE_PAY + hour * HOUR_PAY;
return pay;
}
}
讲师类:
public class Instructor extends Person {
public final double BASE_PAY = 1000; // 基本工资
public final double HOUR_PAY = 35; // 每课时的费用
public double countPay(int hour) {
pay = BASE_PAY + hour * HOUR_PAY;
return pay;
}
}
副教授类:
public class AssistantProfesson extends Person {
public final double BASE_PAY = 1200; // 基本工资
public final double HOUR_PAY = 40; // 每课时的费用
public double countPay(int hour) {
pay = BASE_PAY + hour * HOUR_PAY;
return pay;
}
}
教授类:
public class Professor extends Person {
public final double BASE_PAY = 1400; // 基本工资
public final double HOUR_PAY = 50; // 每课时的费用
public double countPay(int hour) {
pay = BASE_PAY + hour * HOUR_PAY;
return pay;
}
}
测试类:
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class Test {
public static void main(String[] args) {
System.out.println("人员类型如下:");
System.out.println("1 = 助教\r\n2 = 讲师\r\n3 = 副教授\r\n4 = 教授");
System.out.print("请选择:");
BufferedReader personType = new BufferedReader(new InputStreamReader(
System.in));
String type = null;
int hour = 0;
try {
type = personType.readLine();
} catch (Exception e) {
e.printStackTrace();
}
if (type.matches("[1-4]{1}")) {
switch (Integer.valueOf(type)) {
case 1:
hour = getHour();
if(hour == 0){return;}
Person p1 = new Assistant();
double pay1 = p1.countPay(hour);
System.out.println("助教工作" + hour + "课时的工资为:" + pay1);
break;
case 2:
hour = getHour();
if(hour == 0){return;}
Person p2 = new Instructor();
double pay2 = p2.countPay(hour);
System.out.println("讲师工作" + hour + "课时的工资为:" + pay2);
break;
case 3:
hour = getHour();
if(hour == 0){return;}
Person p3 = new AssistantProfesson();
double pay3 = p3.countPay(hour);
System.out.println("副教授工作" + hour + "课时的工资为:" + pay3);
break;
case 4:
hour = getHour();
if(hour == 0){return;}
Person p4 = new Professor();
double pay4 = p4.countPay(hour);
System.out.println("教授工作" + hour + "课时的工资为:" + pay4);
break;
}
} else {
System.out.println("输入数据错误!程序提前推出!");
return;
}
}
public static int getHour() {
System.out.print("请输入工作时间:");
BufferedReader hours = new BufferedReader(new InputStreamReader(
System.in));
String strHour = null;
int hour = 0;
try {
strHour = hours.readLine();
} catch (Exception e) {
e.printStackTrace();
}
if (strHour.matches("^[0-9]+?")) {
hour = Integer.parseInt(strHour);
} else {
System.out.println("输入参数不正确!程序提前推出!");
}
return hour;
}
}
求java源代码 关于员工资薪
用抽象类写最基本的工资计算方法,然后每个不同计算的员工继承这个,使用多态性实例话,大概是这样吧!
当前标题:java工资生成代码 用java编写员工工资
文章出自:http://cdiso.cn/article/hhsoii.html