计算工资

备份用的

 

package com.yl.testproject;

import java.util.Scanner;

public class Erp_yl {

public static void main(String[] args) {
// TODO Auto-generated method stub
// Pay pay = new Pay(1000.0,500.0,10);
double a=0;
double b=0;
int n=0;
int j=0;
// 调用输入10次
for(j=0;j<10;j++) {
Scanner in = new Scanner(System.in);
System.out.println("请输入工资、工龄工资、工龄,空格隔开,然后回车(1 2 3)");
a = in.nextInt();
b = in.nextInt();
n = in.nextInt();

double result = Pay(a,b,n);
System.out.println(result);
}
System.out.println("结束啦啦");

}
// sa 基本工资,p 工龄工资,age工龄
public static double Pay(double sa,double p,int age) {

double res1=0;
double res2=0;
double res=0;

// 计算税后工资
if (sa<1500) {
res1=sa+p;
}
else if(sa>1500 && sa<=3000)
{
res1=sa-(sa*(2/100+3/100));
}
else if(sa>3000 && sa<=6000)
{
res1=sa-(sa*(3/100+4/100));
}
else
{
res1=sa-(sa*(4/100+5/100));
}

// 计算工龄工资
int i;
if (age>1) {
for (i=1;i<age;i++) {
res2=p*(p+30/100);
}
}

// 计算总工资
else
res2=p;
res=res1+res2;

return res;
}

}

posted @ 2019-01-06 22:47  恋恋青柠  阅读(164)  评论(0编辑  收藏  举报