利润
import java.util.Scanner;
public class Test {
public static void main(String[] args) {
//profit代表输入的利润,bonus代表奖金额
double profit = 0, bonus = 0;
System.out.print("请输入本年利润(万):");
Scanner sc = new Scanner(System.in);
profit = sc.nextDouble();
if(profit < 0) {
System.out.print("输入本年利润数据错误,请重新输入:");
profit = sc.nextDouble();
}
if (profit > 0 && profit <= 10) {
bonus= profit*0.1;
} else if (profit > 10 && profit <= 20) {
bonus = 10*0.1 + (profit - 10)*0.075;
} else {
bonus = 10*0.1+10*0.175+(profit - 20)*0.05;
}
System.out.println("应发放的奖金额为:" + bonus+ "万");
}
}
5门课程
import java.util.Scanner;
public class Test {
public static void main(String[] args) {
//average代表5门课的平均值,score代表每门课的成绩,sum代码5门课成绩的总和
double average = 0;
int sum=0,score=0;
System.out.println("请输入5门课的成绩:");
for(int i=1;i<=5;i++) {
System.out.print("请输入第"+i+"门课的成绩:");
Scanner sc = new Scanner(System.in);
score = sc.nextInt();
sum+=score;
}
average=sum/5;
System.out.print("该同学的等级为:");
switch((int)average/10) {
case 9:System.out.println("优"); break;
case 8:System.out.println("良"); break;
case 7:System.out.println("中");break;
case 6:System.out.println("及格");break;
default:System.out.println("不及格");
}
}
}
160-200工资
import java.util.Scanner;
public class Test {
public static void main(String[] args) {
//salary代表应发工资,time代表工作时间
double time = 0,salary = 0;
System.out.print("请输入员工的工作时间(小时):");
Scanner sc = new Scanner(System.in);
time = sc.nextDouble();
if(time < 0) {
System.out.print("输入时间数据错误,请重新输入:");
time = sc.nextDouble();
}
if (time > 0 && time <= 160) {
salary= time *30;
} else if (time > 160 && time <= 200) {
salary = 160*30 + (time - 160)*35;
} else {
salary = 160*30 + 40*35+(time - 200)*40;
}
System.out.println("本员工应发工资为:" + salary);
}
}
6个月考核
import java.util.Scanner;
public class Test {
public static void main(String[] args) {
//score代表每个月的考核成绩,average代表6个月考核的平均值,sum代表总分值
double average = 0;
int sum=0,score=0;
System.out.println("请依次输入6个月的考核成绩:");
for(int i=1;i<=6;i++) {
System.out.print("请输入第"+i+"个月的成绩:");
Scanner sc = new Scanner(System.in);
score = sc.nextInt();
sum+=score;
}
average=sum/6;
System.out.print("该员工的考核等级为:");
switch((int)average/10) {
case 9:System.out.println("优秀"); break;
case 8:System.out.println("良好"); break;
case 7:System.out.println("中等");break;
case 6:System.out.println("合格");break;
default:System.out.println("不合格");
}
}
}
银行存钱
import java.util.Scanner;
public class Test {
public static void main(String[] args) {
//money代表本金,rate代表月利率,total代表本金合计,year代表年限
double money,rate,total;
int year;
System.out.println("请输入本金:");
Scanner sc = new Scanner(System.in);
money=sc.nextDouble();
System.out.println("请输入年限:");
Scanner sc_year = new Scanner(System.in);
year=sc_year.nextInt();
if(year==1) rate=0.00315; /* 根据年限确定利率*/
else if(year==2)rate=0.00330;
else if(year==3) rate=0.00345;
else if(year==5) rate=0.00375;
else if(year==8) rate=0.00420;
else rate=0.0;
total=money + money * rate * 12 * year; /* 计算到期的本利合计*/
System.out.println("本金合计为:"+total);
}
}
160-200超出200每小时40元
import java.util.Scanner;
public class Test {
public static void main(String[] args) {
//salary代表应发工资,time代表工作时间
double time = 0,salary = 0;
System.out.print("请输入员工的工作时间(小时):");
Scanner sc = new Scanner(System.in);
time = sc.nextDouble();
if(time < 0) {
System.out.print("输入时间数据错误,请重新输入:");
time = sc.nextDouble();
}
if (time > 0 && time <= 160) {
salary= time *30;
} else if (time > 160 && time <= 200) {
salary = 160*30 + (time - 160)*30*1.5;
} else {
salary = 160*30 + 40*30*1.5+(time - 200)*30*2;
}
System.out.println("本员工应发工资为:" + salary);
}
}