java个人所得税计算器

  1. class Caculate{  
  2.     private String name;  
  3.     private double money;  
  4.     private double actual;  
  5.     /** 
  6.      * @param username 用户名 
  7.      * @param money 用户税前收入 
  8.      */  
  9.     public Caculate(String username,double money) {  
  10.         this.name=username;  
  11.         this.money=money;  
  12.     }  
  13.       
  14.     public  double HowMany(){  
  15.         //java中switch的case变量只支持int char string,而此处是double,所以不能使用switch  
  16.         double shouru = money;//构造函数中本来已经有this.money了,所以再次使用的使用,用成money即可  
  17.         if(shouru <= 1500){  
  18.             System.out.print("不需要缴纳个人所得税");  
  19.             this.actual=shouru;  
  20.         }else if(1500 < shouru && shouru < 3000){  
  21.             this.actual = shouru*(1 - 0.05);  
  22.         }if(3000 <= shouru){  
  23.             this.actual=shouru-(shouru-3000)*0.1;  
  24.         }  
  25.         System.out.println("实际收入为:"+this.actual);  
  26.           
  27.           
  28.         return this.actual;  
  29.     }  
  30. }  
  31. /** 
  32.  * @author 码农小江 
  33.  * PersonalFax.java 
  34.  * 2012-8-7下午11:28:16 
  35.  */  
  36. public class PersonalFax {  
  37.     public static void main(String args[]){  
  38.         Caculate  shiji = new Caculate("码农小江", 1000.2345);  
  39.         double shou =shiji.HowMany();  
  40.         System.out.printf("%.3f", shou);  
  41.                   
  42.     }  
  43.   
  44. }  

posted on 2016-08-17 16:47  Java初级码农  阅读(7250)  评论(0编辑  收藏  举报

导航