重庆分公司,新征程启航

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

java工资计算代码 java计算工资的计算例题

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算工资的编程题?

class Salary{

private int no;

private String name;

private double deal;

private double tax;

public Salary(int no,String name,double deal,double tax){

this.no=no;

this.name=name;

this.deal=deal;

this.tax=tax;

}

public double count(){

return this.deal-this.tax;

}

public void output(){

System.out.println("工号缓数腔"+this.no);

System.out.println("姓名"+this.name);

System.out.println("应发工资"+this.deal);

System.out.println("税毕高金"+this.tax);

System.out.println("实发工资"+count());

}

public static void main(String[] args){

Salary a=new Salary(1,"张三",1000,200);

a.output();

Salary b=new Salary(2,"扰衫李四",1500,200);

b.output();

}

}


新闻标题:java工资计算代码 java计算工资的计算例题
分享网址:http://cqcxhl.cn/article/ddpjjsd.html

其他资讯

在线咨询
服务热线
服务热线:028-86922220
TOP