1.奖励机制
import java.util.Scanner;
public class test01 {
public static void main(String[] args) {
Scanner sc =new Scanner(System.in);
System.out.println("请输入存款金额:");
double money = sc.nextDouble();
if (money>1000000){
System.out.println("宝马X5");
}else if (money>500000){
System.out.println("奥迪A6");
}else if (money>200000){
System.out.println("比亚迪");
}else if (money>100000){
System.out.println("极品飞车");
}else {
System.out.println("好好努力");
}
}
}
import java.util.Scanner;
public class test02 {
public static void main(String[] args) {
Scanner sc= new Scanner(System.in);
System.out.println("请录入学员分数:");
int num=sc.nextInt();
if (num<=100 && num>90){
System.out.println("奖励一个iPhone13和一个iPad");
}else if (num>80&&num<=90){
System.out.println("奖励iPhone13一台");
}else{
System.out.println("不予奖励,罚一个iphone13");
}
}
}
2.个人所得税计算
import java.util.Scanner;
public class test03 {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
System.out.println("请输入工资所得:");
double salary=sc.nextDouble();
double deduction=3500;//扣除数
double taxSalary = salary-deduction;
double deDuction =0;
double taxRate=0;
if (taxSalary>0){
if (taxSalary<1500){
taxRate=0.03;
deduction=0;
}else if(taxSalary<4500){
taxRate=0.10;
deduction=105;
}else if(taxSalary<9000){
taxRate=0.20;
deduction=555;
}else if(taxSalary<35000){
taxRate=0.25;
deduction=1005;
}else if(taxSalary<55000){
taxRate=0.30;
deduction=2755;
}else if(taxSalary<80000){
taxRate=0.35;
deduction=5505;
}else {
taxRate=0.45;
deduction=13505;
}
double taxPayment=taxSalary*taxRate-deduction;
System.out.println("当月应上税多少钱:"+taxPayment);
}
}
}
3.switch语句练习
/**
switch的使用练习;
2023年4月25日22点49分
*/
import java.util.Scanner;
public class test05 {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
System.out.println("请输入1到7中的一个数字:");
int num=sc.nextInt();
switch (num){
case 1:
System.out.println("星期一");
break;
case 2:
System.out.println("星期二");
break;
case 3:
System.out.println("星期三");
break;
case 4:
System.out.println("星期四");
break;
case 5:
System.out.println("星期五");
break;
case 6:
System.out.println("星期六");
break;
case 7:
System.out.println("星期日");
break;
default:
System.out.println("输入出错!");
break;
}
}
}
//平年闰年的判断
import java.util.Scanner;
public class test06 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("请输入年份:");
int year =sc.nextInt();
System.out.println("请输入月份:");
int month =sc.nextInt();
int day=0;
switch (month){
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
day=31;
break;
case 4:
case 6:
case 9:
case 11:
day=30;
break;
case 2:
if (year%400==0 || (year%4==0&&year%100!=0)){
day=29;
}else {
day=28;
}
break;
default:
System.out.println("输入错误");
break;
}
System.out.println(year+"年"+month+"月共有"+day+"天");
}
}