302班

          java突擊隊
          posts - 151, comments - 74, trackbacks - 0, articles - 14
            BlogJava :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理

          if else語句實現(xiàn)稅率征收

          Posted on 2007-04-08 12:05 停留的風(fēng) 閱讀(488) 評論(0)  編輯  收藏 所屬分類: Java程序集合


          import javax.swing.JOptionPane;
          public class taxQuestion
          {
            public static void main(String[] args)
            {
             //輸入基準(zhǔn)值
             String statusString=JOptionPane.showInputDialog(null,"Enter the filing status:\n"+"(0-single filer,1-married jointly,\n)"+"2-married separately,3-head of household)","Input a status",JOptionPane.QUESTION_MESSAGE);
             int status=Integer.parseInt(statusString);
             //輸入收入値
             String incomeString=JOptionPane.showInputDialog(null,"Enter the taxable income:","Give me your money",JOptionPane.QUESTION_MESSAGE);
             Double income=Double.parseDouble(incomeString);
             double tax=0;
          if(status==0)
            {
             if(income<=1200)
              JOptionPane.showMessageDialog(null,"You should not pay for the tax!","The show of the result",JOptionPane.INFORMATION_MESSAGE);
             else if(income<=3000)
             {
              tax=(income-1200)*0.10;
             JOptionPane.showMessageDialog(null,"You should pay"+tax+"for the tax!","The show of the result",JOptionPane.INFORMATION_MESSAGE);
             }
             else if(income<=10000)
             {
              tax=(income-3000)*0.15;
              JOptionPane.showMessageDialog(null,"You should pay"+tax+"for the tax!","The show of the result",JOptionPane.INFORMATION_MESSAGE);
             }
             else if(income<300000)
             { 
               tax=(income-10000)*0.30;
               JOptionPane.showMessageDialog(null,"You should pay"+tax+"for the tax!","The show of the result",JOptionPane.INFORMATION_MESSAGE);
             }
             else
             {
               tax=(income-300000)*0.80;
               JOptionPane.showMessageDialog(null,"You should pay"+tax+"for the tax!","The show of the result",JOptionPane.INFORMATION_MESSAGE);
             }
            }
             else
             {
               tax=(income-status);
              JOptionPane.showMessageDialog(null,"You should pay"+tax+"for the tax!","The show of the result",JOptionPane.INFORMATION_MESSAGE);
             }
           }
          }
          /////////////////////////////////////////////////////////////////////////
          測試結(jié)果簡要如下:
          ////////////////////////////////////////////////////////////////////////




          主站蜘蛛池模板: 黑山县| 盐亭县| 华坪县| 错那县| 云阳县| 丰都县| 四平市| 桐柏县| 来凤县| 桐乡市| 边坝县| 博兴县| 高清| 汪清县| 寿宁县| 永福县| 巴马| 沁源县| 台州市| 茂名市| 渝中区| 巴林右旗| 云梦县| 奉化市| 方山县| 苏尼特左旗| 通山县| 高唐县| 奉贤区| 平泉县| 临泽县| 沅陵县| 舟山市| 武威市| 仙游县| 贵德县| 枞阳县| 万载县| 乃东县| 富顺县| 正安县|