1、换手机问题
李雷想买一个价值7988元的新手机,她的旧手机在二手市场能卖1500元, 而手机专卖店推出以旧换新的优惠,把她的旧手机交给店家,新手机就能够打8折优惠。 为了更省钱,李雷要不要以旧换新?请在控制台输出。
public class Test1 {
public static void main(String[] args) {
int firstWay = 1500;
double secondWay = 7900 * (1 - 0.8);
if (secondWay >= firstWay) {
System.out.println("以旧换新吧!");
} else {
System.out.println("不要以旧换新");
}
}
}
2、让用户依次录入三个整数,求出三个数中的最小值,并打印到控制台。
public class Test2 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("请输入第一个数:");
int first = sc.nextInt();
System.out.println("请输入第二个数:");
int second = sc.nextInt();
System.out.println("请输入第三个数:");
int third = sc.nextInt();
int temp = first > second ? first : second;
int max = temp > third ? temp : third;
System.out.println("最大值是:" + max);
}
}
3、银行存款问题
某银行推出了整存整取定期储蓄业务,其存期分为一年、两年、三年、五年,到期凭存单支取本息。存款年利率表如下: 存期 年利率(%) 一年 2.25 两年 2.7 三年 3.25 五年 3.6 请输入存入一定金额(1000起存),存一定年限(四选一),计算到期后得到的本息总额 提示: 存入金额和存入年限均由键盘录入 本息计算方式:本金+本金×年利率×年限
public class Test3 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("请输入您的存款数额:");
int money = sc.nextInt();
if (money >= 1000) {
System.out.println("请输入您的存款年限:");
int year = sc.nextInt();
double rel = 0;
switch (year) {
case 1:
rel = money + money * 0.0225 * 1;
break;
case 2:
rel = money + money * 0.027 * 2;
break;
case 3:
rel = money + money * 0.0325 * 3;
break;
case 5:
rel = money + money * 0.036 * 5;
break;
default:
System.out.println("暂时没有该年限的存储活动!");
}
System.out.println(rel);
} else {
System.out.println("您的存款数量输入不合法哦!存款数额不得少于1000!");
}
}
}
4、商城购物问题
某商场购物可以打折,具体规则如下: 普通顾客购不满100元不打折,满100元打9折; 会员购物不满200元打8折,满200元打7.5折; 不同打折规则不累加计算。 请根据此优惠计划进行购物结算,键盘录入顾客的类别(0表示普通顾客,1表示会员) 和购物的折前金额(整数即可),输出应付金额(小数类型)。
public class Test4 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("请输入折前金额:");
double money = sc.nextDouble();
if (money > 0) {
System.out.println("请输入顾客类别(0表示普通顾客,1表示会员):");
int type = sc.nextInt();
if (type == 1) {
if (money < 200) {
double relMoney = money * 0.8;
System.out.println(relMoney);
} else {
double relMoney = money * 0.75;
System.out.println(relMoney);
}
} else if (type == 0) {
if (money < 100) {
double relMoney = money;
System.out.println(relMoney);
} else {
double relMoney = money * 0.9;
System.out.println(relMoney);
}
} else {
System.out.println("您输入的顾客类别不合法!");
}
} else {
System.out.println("您输入的金额不合法!");
}
}
}
5、梯度交税问题
2019年1月1日起,国家推出新的个人所得税政策,起征点上调值5000元。 也就是说税前工资扣除三险一金(三险一金数额假设是税前工资的10%)后如果不足5000元,则不交税。 如果大于5000元,那么大于5000元的部分按梯度交税,具体梯度比例如下: 0 ~ 3000元的部分,交税3% 3000 ~ 12000元的部分,交税10% 12000 ~ 25000的部分 , 交税20% 25000 ~ 35000的部分,交税25% 35000 ~ 55000的部分,交税30% 55000 ~ 80000的部分,交税35% 超过80000的部分,交税45% 比如:某人入职一家企业后,税前工资是15000, 则他每月该交个税的部分是15000-1500-5000=8500元, 个税缴纳数额是3000×3%+5500×10%=640元。 税后工资12860元。 请完成一个个税计算程序,在用户输入税前工资后,计算出他对应的纳税数额,以及税后工资为多少?
public class Test5 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("请输入税前工资:");
int money = sc.nextInt();
double tax = money * 0.1;
if (money > 0) {
double initalMoney = money * (1 - 0.1);
if (initalMoney > 5000) {
initalMoney = initalMoney - 5000;
if (initalMoney <= 3000) {
tax += initalMoney * 0.03;
double rel = money - tax;
System.out.println(rel);
} else if (initalMoney > 3000 && initalMoney <= 12000) {
tax += 3000 * 0.03 + (initalMoney - 3000) * 0.1;
double rel = money - tax;
System.out.println(rel);
} else if (initalMoney > 12000 && initalMoney <= 25000) {
tax += 3000 * 0.03 + 9000 * 0.1 + (initalMoney - 12000) * 0.1;
double rel = money - tax;
System.out.println(rel);
} else if (initalMoney > 25000 && initalMoney <= 35000) {
tax += 3000 * 0.03 + 9000 * 0.1 + 13000 * 0.2 + (initalMoney - 25000) * 0.25;
double rel = money - tax;
System.out.println(rel);
} else if (initalMoney > 35000 && initalMoney <= 55000) {
tax += 3000 * 0.03 + 9000 * 0.1 + 13000 * 0.2 + 10000 * 0.25
+ (initalMoney - 35000) * 0.3;
double rel = money - tax;
System.out.println(rel);
} else if (initalMoney > 55000 && initalMoney <= 80000) {
tax += 3000 * 0.03 + 9000 * 0.1 + 13000 * 0.2 + 10000 * 0.25 + 20000 * 0.3
+ (initalMoney - 55000) * 0.35;
double rel = money - tax;
System.out.println(rel);
} else {
tax += 3000 * 0.03 + 9000 * 0.1 + 13000 * 0.2 + 10000 * 0.25 + 20000 * 0.3 + 25000 * 0.35
+ (initalMoney - 80000) * 0.45;
double rel = money - tax;
System.out.println(rel);
}
} else {
double rel = money - tax;
System.out.println(rel);
}
} else {
System.out.println("您输入的税前工资不合法!");
}
}
}
6、