luanpaixie262
2016-03-14 15:01
采纳率: 54.8%
浏览 1.4k
已采纳

这个题目怎么写我不太会写,薪水问题求各位大神教教我

大神教教这题怎么写?这个我不太会写,感觉没有思路啊⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯图片说明

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

5条回答 默认 最新

  • blownewbee 2016-03-14 15:28
    已采纳
     public static double foo(int x) {
    if (x <= 3500) return 0;
    if (x <= 5000) return (x - 3500) * 0.03;
    if (x <= 8000) return (x - 5000) * 0.1 + 1500 * 0.03;
    return (x - 8000) * 0.2 + 3000 * 0.1 + 1500 * 0.03;
    }
    public static void main(String[] args) 
    {
        Scanner in = new Scanner(System.in);
            int x = in.nextInt();
        System.out.println(foo(x));
    }
    
    点赞 评论
  • 夜半无声 2016-03-14 15:33
      public static void main(String[] args) {
            Scanner sc = new Scanner(System.in);
            while (true) {
                try {
                    int guessNumber = sc.nextInt();
                    if (guessNumber > 8000) {
                        int num1 = guessNumber - 8000;
                        int num2 = 8000 - 5000;
                        int num3 = 5000 - 3500;
                        System.out.println(num1 * 0.2 + num2 * 0.1 + num3 * 0.03);
                    } else if (guessNumber < 8000 && guessNumber > 5000) {
                        int num1 = guessNumber - 5000;
                        int num2 = 5000 - 3500;
                        System.out.println(num1 * 0.1 + num2 * 0.3);
                    } else if (guessNumber < 5000 && guessNumber > 3500) {
                        System.out.println((guessNumber - 3500) * 0.03);
                    } else {
                        System.out.println("不交税");
                    }
                } catch (InputMismatchException e) {
                    System.out.println("输入金额有误");
                }
            }
        }
    
    点赞 评论
  • XoapQ 2016-03-14 15:47
        新手写码,不规范请见谅
        double b = -1;
        Scanner input=new Scanner(System.in);
        System.out.println("请输入薪水:");
        double a=input.nextInt();
    
        if(a>0&&a<=3500){
            b=0;
        }else if(a>3500&&a<=5000){
            b=(a-3500)*0.03;
        }else if(a>5000&&a<=8000){
            b=1500*0.03+(a-5000)*0.1;
        }else if(a>8000){
            b=1500*0.03+3000*0.1+(a-8000)*0.2;
        }
    
        if(b==0){
            System.out.println("不交税");        
        }else{
            System.out.println("个人所得税:"+b);
        }
    
    点赞 评论
  • 103style 2016-03-15 00:43

    public static double foo(int x) {
    if (x <= 3500) return 0;
    if (x <= 5000) return (x - 3500) * 0.03;
    if (x <= 8000) return (x - 5000) * 0.1 + 1500 * 0.03;
    return (x - 8000) * 0.2 + 3000 * 0.1 + 1500 * 0.03;
    }
    public static void main(String[] args)
    {
    Scanner in = new Scanner(System.in);
    int x = in.nextInt();
    System.out.println(foo(x));
    }

    点赞 评论
  • 大胖出奇迹 2016-03-15 05:49

    新手!

    import java.util.Scanner;

    public class Test {

    public static void main(String[] args) {
    
        while (true) {
            System.out.println("请输入薪水:");
            Scanner sc = new Scanner(System.in);
            int i = sc.nextInt();
            double m = test(i);
    
            if (m < 0) {
                System.out.println("应交税" + 0);
            } else {
    
                System.out.println("应交税:" + m + " !");
            }
        }
    
    }
    
    public static double test(int i) {
    
        double m = 0;
        switch (i / 1000) {
    
        default:
            m = m + ((i - 8000) * 0.2);
        case 7:
            if (i < 8000) {
                m = m + ((i - 7000) * 0.1);
            } else {
                m = m + ((1000) * 0.1);
            }
        case 6:
            if (i < 7000) {
                m = m + ((i - 6000) * 0.1);
            } else {
                m = m + (1000 * 0.1);
            }
        case 5:
            if (i < 6000) {
                m = m + ((i - 5000) * 0.1);
            } else {
                m = m + (1000 * 0.1);
            }
        case 4:
            if (i < 5000) {
                m = m + ((i - 4000) * 0.03);
            } else {
                m = m + (1000 * 0.03);
            }
        case 3:
            if (i < 4000) {
                m = m + ((i - 3500) * 0.03);
            } else {
                m = m + (500 * 0.03);
            }
    
            break;
    
        }
    
        return m;
    
    }
    

    }

    点赞 评论

相关推荐 更多相似问题