分析以下需求,并用代码实现:
(1)根据工龄(整数)给员工涨工资(整数),工龄和基本工资通过键盘录入
(2)涨工资的条件如下:
[10-15) +5000
[5-10) +2500
[3~5) +1000
[1~3) +500
[0~1) +200
(3)如果用户输入的工龄为10,基本工资为3000,程序运行后打印格式"您目前工作了10年,基本工资为 3000元, 应涨工资 5000元,涨后工资 8000元"
import java.util.Scanner;
class Zuo1{
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("输入工龄");
int x = sc.nextInt();
System.out.println("输入基本工资");
int y = sc.nextInt();
if (x >=10 & x <15)
{
int z = 5000;
int sum = z + y;
System.out.println("您目前工作了" + x + "年" +",基本工资为" + y + "元" + ",应涨工资" + z + "元" + ",涨后工资" + sum +"元");
}else if (x >=5 & x <10)
{
int z = 2500;
int sum = z + y;
System.out.println("您目前工作了" + x + "年" +",基本工资为" + y + "元" + ",应涨工资" + z + "元" + ",涨后工资" + sum +"元");
}else if (x >=3 & x < 5)
{
int z = 1000;
int sum = z + y;
System.out.println("您目前工作了" + x + "年" +",基本工资为" + y + "元" + ",应涨工资" + z + "元" + ",涨后工资" + sum +"元");
}else if (x >=1 & x <3)
{
int z = 500;
int sum = z + y;
System.out.println("您目前工作了" + x + "年" +",基本工资为" + y + "元" + ",应涨工资" + z + "元" + ",涨后工资" + sum +"元");
}else if (x == 0)
{
int z = 200;
int sum = z + y;
System.out.println("您目前工作了" + x + "年" +",基本工资为" + y + "元" + ",应涨工资" + z + "元" + ",涨后工资" + sum +"元");
}else {
System.out.println("无法识别你的工龄");
}
}
} |
|