zoukankan      html  css  js  c++  java
  • 【c语言趣味编程100例】个人所得税

    #include<stdio.h>
    #define TAXBASE 3500
    typedef struct{
    	long start; //起征点
    	long end;   //终点
    	double taxrate;//利率
    }TAXTABLE;
    
    TAXTABLE taxTABLE [] = {{0,1500,0.03},{1500,4500,0.10},{4500,9000,0.20},{9000,35000,0.25}};
    double CaculateTax(long profit){
    	int i;
    	double tax = 0.0;
    	profit-=TAXBASE;
    	for(i=0;i<sizeof(taxTABLE)/sizeof(TAXBASE);i++){
    		if(profit>taxTABLE[i].start){
    		
    			if(profit>taxTABLE[i].end){
    				tax+=(taxTABLE[i].end-taxTABLE[i].start)*
    					taxTABLE[i].taxrate;
    			}else{
    				tax+=(profit-taxTABLE[i].start)*taxTABLE[i].taxrate;
    			}
    			profit-=taxTABLE[i].end;
    
    			//printf("征税范围:%61d-%61d 该范围的缴纳税金额:%6.2f ",taxTABLE[i].start,taxTABLE[i].end,tax,(profit)>0?profit:0);
    		}
    	
    	}
    		return tax;
    
    }
    
    void main(){
    	
    	long profit;
    	double tax;
    	printf("请输入个人金额:");
    	scanf("%ld",&profit);
    	tax = CaculateTax(profit);
    	printf("您的个人所得税为:%12.2f
    ",tax);
    
    	
    
    
    }
    
  • 相关阅读:
    访问者模式
    中介者模式
    策略模式
    迭代器模式
    责任链模式
    contentProvider模板
    android studio常用快捷键(不断补充)
    jqgrid表格列动态加载的实现
    Android View.onMeasure方法的理解(转载)
    activity的生命周期
  • 原文地址:https://www.cnblogs.com/qxlxi/p/12860858.html
Copyright © 2011-2022 走看看