java個人所得稅計算器


  • class Caculate{  
  •     private String name;  
  •     private double money;  
  •     private double actual;  
  •     /** 
  •      * @param username 用戶名 
  •      * @param money 用戶稅前收入 
  •      */  
  •     public Caculate(String username,double money) {  
  •         this.name=username;  
  •         this.money=money;  
  •     }  
  •       
  •     public  double HowMany(){  
  •         //java中switch的case變量只支持int char string,而此處是double,所以不能使用switch  
  •         double shouru = money;//構造函數中本來已經有this.money了,所以再次使用的使用,用成money即可  
  •         if(shouru <= 1500){  
  •             System.out.print("不需要繳納個人所得稅");  
  •             this.actual=shouru;  
  •         }else if(1500 < shouru && shouru < 3000){  
  •             this.actual = shouru*(1 - 0.05);  
  •         }if(3000 <= shouru){  
  •             this.actual=shouru-(shouru-3000)*0.1;  
  •         }  
  •         System.out.println("實際收入為:"+this.actual);  
  •           
  •           
  •         return this.actual;  
  •     }  
  • }  
  • /** 
  •  * @author 碼農小江 
  •  * PersonalFax.java 
  •  * 2012-8-7下午11:28:16 
  •  */  
  • public class PersonalFax {  
  •     public static void main(String args[]){  
  •         Caculate  shiji = new Caculate("碼農小江", 1000.2345);  
  •         double shou =shiji.HowMany();  
  •         System.out.printf("%.3f", shou);  
  •                   
  •     }  
  •   
  • }  

  • 免責聲明!

    本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



     
    粵ICP備18138465號   © 2018-2025 CODEPRJ.COM