IF选择结构例题(银行利率问题)

IF选择结构例题(银行利率问题)

if…else 选择

利率、税收问题

/*某银行推出了整存整取定期储蓄业务,其存期分为一年、两年、三年、五年,
  到期凭存单支取本息。存款年利率表如下:
  存期年利率(%)
  一年2.25
  两年2.7
  三年3.25
  五年3.6
  请存入一定金额(1000起存),存一定年限(四选一),计算到期后得到的本息总额。
  提示:
  存入金额和存入年限均由键盘录入
  本息计算方式:本金+本金×年利率×年限
*/

import java.util.Scanner;

public class Deposit{
	
	public static void main(String [] args){
	Scanner input = new Scanner(System.in);
	System.out.print("请输入存入金额:");
	double money = input.nextDouble();
	System.out.print("请输入存入年限(1/2/3/5年):");
	int years = input.nextInt();
	if (money >= 1000) {
		double total = 0;
		if (years  == 1) {
			total = money + money * 0.0225 * 1;	
		} else if (years == 2) {
			total = money + money * 0.027 * 2;	
		} else if (years == 3) {
			total = money + money * 0.0325 * 3;	
		} else if (years == 5) {
			total = money + money * 0.036 * 5;	
		}
			System.out.println("本息总额:" + total);
	} else {
		System.out.println("金额过低,请重新输入");
		return;
	}
	}
}








/*
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%
*/

import java.util.Scanner;

public class Taxation{
	public static void main(String [] args){
	Scanner input = new Scanner(System.in);
	System.out.print("请输入工资(单位/元):");
	double money = input.nextDouble();
	//税后工资 = 税前工资 - 三险一金(税前工资的10%)- 税收(交税部分乘以对应税率)
	//三险一金
	double money1 = money * 0.9;
	if( money1 > 5000 ){
		//定义需要交税部分的工资
		double tax = (money * 0.9) - 5000;
		//定义税后工资
		double money2;
		//定义税收
		double tax1;		
		if ( tax > 0 && tax <= 3000){
			tax1 = (tax * 0.03);
			money2 = money1 - tax1;
		} else if (tax > 3000 && tax <= 12000){
			tax1 = ((tax - 3000) * 0.1 + 90);
			money2 = money1 - tax1;	
		} else if ( tax > 12000 && tax <= 25000){
			tax1 = ((tax - 12000) * 0.2 + 990);
			money2 = money1 - tax1;
		} else if ( tax > 25000 && tax <= 35000){
			tax1 = ((tax - 25000) * 0.25 + 990 + 2600);
			money2 = money1 - tax1;
		} else if ( tax > 35000 && tax <= 55000){
			tax1 = ((tax - 35000) * 0.3 + 990 + 2600 + 2500);
			money2 = money1 - tax1;
		} else if ( tax > 55000 && tax <= 80000){
			tax1 = ((tax - 55000) * 0.35 + 990 + 2600 + 2500 + 6000);
			money2 = money1 - tax1;
		} else {
			tax1 = ((tax - 55000) * 0.35 + 990 + 2600 + 2500 + 6000 + 8750);
			money2 = money1 - tax1;
		}
		System.out.println("扣除保险以及税收后工资:" + money2 + ",交税:"  + tax1);
	} else 
		System.out.println("扣除保险后工资:" + (money * 0.9) + ",交税:0" );
	}
} 
  • 2
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值