1. Java / Говнокод #26028

    +1

    1. 1
    float sales = new Integer(getSalesCount()).floatValue();

    someone, 13 Ноября 2019

    Комментарии (17)
  2. Java / Говнокод #25998

    +1

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    import java.util.Scanner;
    
    public class ComputeTax {
    
    public static void main(String[] args) {
    // Create a Scanner
    Scanner input = new Scanner(System.in);
    
    // Prompt the user to enter filing status
    System.out.print(
        "(0-single filer, 1-married jointly or qualifying widow(er)",
        + "\n2-married separately, 3-head of household)\n" +
        "Enter the filing status: ");
    int status = input.nextInt();
    
    // Prompt the user to enter taxable income
    System.out.print("Enter the taxable income: ");
    double income = input.nextDouble();
    
    // Compute tax
    double tax = 0;
    
    if (status == 0) {// Compute tax for single filers
        if (income <= 8350)
              tax = income * 0.10;
        else if (income <= 33950)
              tax = 8350 * 0.10 + (income - 8350) * 0.15;
        else if (income <= 82250)
              tax = 8350 * 0.10 + (33950 - 8350) * 0.15 +
             (income - 33950) * 0.25;
        else if (income <= 171550)
              tax = 8350 * 0.10 + (33950 - 8350) * 0.15 +
             (82250 - 33950) * 0.25 + (income - 82250) * 0.28;
        else if (income <= 372950)
              tax = 8350 * 0.10 + (33950 - 8350) * 0.15 +
              (82250 - 33950) * 0.25 + (171550 - 82250) * 0.28 +
              (income - 171550) * 0.33;
        else
              tax = 8350 * 0.10 + (33950 - 8350) * 0.15 +
             (82250 - 33950) * 0.25 + (171550 - 82250) * 0.28 +
             (372950 - 171550) * 0.33 + (income - 372950) * 0.35;
    }
    else if (status == 1) {
    // Left as exercise
    // Compute tax for married file jointly or qualifying widow(er)
    }
    else if (status == 2) {
    // Compute tax for married separately
    // Left as exercise
    }
    else if (status == 3) {
    // Compute tax for head of household
    // Left as exercise
    }
    else {
        System.out.println("Error: invalid status");
        System.exit(1);
    }
    // Display the result
    System.out.println("Tax is " + (int)(tax * 100) / 100.0);
    
    }

    Ksyrx, 26 Октября 2019

    Комментарии (52)
  3. Java / Говнокод #25947

    −3

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    63. 63
    64. 64
    65. 65
    66. 66
    67. 67
    68. 68
    69. 69
    70. 70
    71. 71
    72. 72
    73. 73
    74. 74
    75. 75
    76. 76
    77. 77
    78. 78
    79. 79
    80. 80
    81. 81
    82. 82
    83. 83
    84. 84
    85. 85
    86. 86
    87. 87
    88. 88
    89. 89
    90. 90
    91. 91
    92. 92
    93. 93
    94. 94
    95. 95
    96. 96
    97. 97
    98. 98
    99. 99
    import java.util.Random;
    public class Main {
        public static void main(String[] args) {
            Galaxy g = new Galaxy(3,77,34);
            g.start();
        }
    }
    class Galaxy extends Thread {
        private int min = 1;
        private int max = 100;
        private final int step = 5;
        private final int TIME = 1000;
        volatile private int a, b, c;
        Galaxy(int a, int b, int c) {
            this.a = a;
            this.b = b;
            this.c = c;
        }
        public void start() {
            Thread t = new Thread(this, "one");
            t.start();
            Thread t2 = new Thread(this, "two");
            t2.start();
            Thread t3 = new Thread(this, "three");
            t3.start();
        } @Override
        public void run() { while(true) { try {
                    Thread.sleep(new Random().nextInt(TIME));
                    if(currentThread().getName().equals("one")) {
                        if(new Random().nextInt(2) == 1 && a > 0)
                            a--;
                        else {
                            if (a < max)
                                a++;
                        }
                        int var = a;
                        if(b == var || (b-1) == var || (b+1) == var)
                            if((b+step) > max)
                                b-=step;
                            if((b-step) < min)
                                b+=step;
                        if(c == var || (c-1) == var || (c+1) == var)
                            if((c+step) > max)
                                c-=step;
                            if((c-step) < min)
                                c+=step;
                    }
                  if(currentThread().getName().equals("two")) {
                        if(new Random().nextInt(2) == 1 && b > 0)
                            b--;
                        else {
                            if(b < max)
                                b++;
                        }
                        int var = b;
                        if(a == var || (a-1) == var || (a+1) == var) {
                            if((a+step) > max)
                                a-=step;
                            if((a-step) <= min)
                                a+=step;
                        }
                        if(c == var || (c-1) == var || (c+1) == var) {
                            if((c+step) > max)
                                c-=step;
                            if((c-step) <= min)
                                c+=step;
                        }
                    }
                   if(currentThread().getName().equals("three")) {
                        if(new Random().nextInt(2) == 1 && c > 0)
                            c--;
                        else {
                            if(c < max)
                                c++;
                        }
                        int var = c;
                        if(a == var || (a-1) == var || (a+1) == var) {
                            if((a+step) > max)
                                a-=step;
                            if((a-step) <= min)
                                a+=step;
                        }
                        if(b == var || (b-1) == var || (b+1) == var) {
                            if((b+step) > max)
                                b-=step;
                            if((b-step) <= min)
                                b+=step;
                        }
                    }
                    for(int i = min; i <= max; i++) {
                        int p = 0;
                        if(i == a || i == b || i == c)
                            p = 1;
                        System.out.print(p);
                    }
                    System.out.println();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }}}}

    После запуска ждал 10 минут. Но они так и не сблизились. Программа словно остерегается сближения. Как живая.
    Рашан ИИ!

    codershitter, 14 Октября 2019

    Комментарии (9)
  4. Java / Говнокод #25915

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    public class Main {
        public static void main(String[] args) {
            Runtime r = Runtime.getRuntime();
            Process p = null;
            long s = System.currentTimeMillis();
            try {
                p = r.exec("find /");
            } catch(Exception e) {
                System.out.println("Ой!");
            }
            while(p != null ? p.isAlive() : true) {
                //$_$//
            }
            System.out.println(p.exitValue()+(System.currentTimeMillis()-s));
        }
    }

    Это написал победитель уральского програмсофта
    Рашан программерс!

    codershitter, 07 Октября 2019

    Комментарии (9)
  5. Java / Говнокод #25884

    +2

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    public void addDisplayMethodNoAttribute()
    {
            addHeaderMethod();
            pyScript.append("def doPrint(row, columns):\n");
            pyScript.append("  line=\"\"\n");
            pyScript.append("  for column in columns:\n");
            pyScript.append("    if(line == \"\"):\n");
            pyScript.append("      line = line + str(row[column])\n");
            pyScript.append("    else:\n");
            pyScript.append("      if(column == \"translations\"):\n");
            pyScript.append("        line = line + separator+ \"[\"\n");
            pyScript.append("        buf = \"\"\n");
            pyScript.append("        for item in row[column]:\n");
            pyScript.append("          if(buf != \"\"):\n");
            pyScript.append("            buf = buf + \", \"\n");
            pyScript.append(
                    "          buf = buf + \"[\" + str(item[\"source\"]) + \", \" + item[\"code\"] + \", \" + item[\"comment\"] + \"]\"\n");
            pyScript.append("        line = line + buf + \"]\"\n");
            pyScript.append("      else:\n");
            pyScript.append("        line = line + separator + str(row[column])\n");
            pyScript.append("  print(line)\n");
            pyScript.append("\n");
            pyScript.append("list = df.collect()\n");
            pyScript.append("for row in list:\n");
            pyScript.append("    doPrint(row, df.columns)\n");
            pyScript.append("\n");
            addSessionDestroy();
            generatePySparkScript();
    }

    Мне пытались объяснить что так лучше из-за того что не все люди знают питон, и из-за этого будем генерить его в Java.

    kazuzbek, 30 Сентября 2019

    Комментарии (3)
  6. Java / Говнокод #25882

    +1

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    63. 63
    64. 64
    public class Main {
        public static void main(String[] args) {
            ThreeD[] f = {new ThreeD(5, 9, 7), new FourD(1,3,8,5)};
            Coords<ThreeD> c = new Coords<>(f);
            showXYZ(c);
            FiveD[] x = new FiveD[] {new FiveD(11,22,3,4, 123)};
            Coords<FiveD> b = new Coords<>(x);
            showAll(b);
            FiveD[] z = new FiveD[] {new FiveD(1,2,1,6,5)};
            Coords<FiveD> zz = new Coords<>(z);
        }
        private static void showXY(Coords<? super FourD> c) {
            for(int i = 0; i < c.coords.length; i++) {
                System.out.println(c.coords[i].x +" "+ c.coords[i].y+" ");
            }
        }
    
        private static void showXYZ(Coords<? extends ThreeD> c) {
            for(int i = 0; i < c.coords.length; i++) {
                System.out.println(c.coords[i].x +" "+ c.coords[i].y+" "+c.coords[i].z+" ");
            }
        }
        private static void showAll(Coords<? extends FiveD> c) {
            for(int i = 0; i < c.coords.length; i++) {
                System.out.println(c.coords[i].x +" "+ c.coords[i].y+" "+c.coords[i].z+" "+c.coords[i].t+" "+c.coords[i].m);
            }
        }
    }
    
    class Coords<T extends TwoD> {
        T[] coords;
        Coords(T[] o) {
            coords = o;
        }
    }
    
    class TwoD {
        int x,y;
        TwoD(int a, int b) {
            x = a;
            y = b;
        }
    }
    class ThreeD extends TwoD {
        int z;
        ThreeD(int a, int b, int c) {
            super(a, b);
            z = c;
        }
    }
    class FourD extends ThreeD {
        int t;
        FourD(int a, int b, int c, int d) {
            super(a, b, c);
            t = d;
        }
    }
    class FiveD extends FourD {
        int m;
        FiveD(int a, int b, int c, int d, int e) {
            super(a, b, c, d);
            m = e;
        }
    }

    говнецо или нет

    codershitter, 29 Сентября 2019

    Комментарии (56)
  7. Java / Говнокод #25771

    +1

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    public class Uptime {
        private short minute;
        private byte hour;
        private short day;
        private short month;
        private short year;
        
        public Uptime() {
            ScheduledExecutorService executorService = Executors.newSingleThreadScheduledExecutor();
            executorService.scheduleAtFixedRate(() -> {
                minute++;
                if(minute >= 61) {
                    hour++;
                    minute = 0;
                    if(hour >= 25) {
                        day++;
                        hour = 0;
                        if(day >= 31) {
                            month++;
                            day = 0;
                            if(month >= 13) {
                                year++;
                                month = 0;
                            }
                        }
                    }
                }
            }, 1, 1, TimeUnit.MINUTES);
        }
    
        public short getMinute() {
            return minute;
        }
    
        public byte getHour() {
            return hour;
        }
    
        public short getDay() {
            return day;
        }
    
        public short getMonth() {
            return month;
        }
    
        public short getYear() {
            return year;
        }
    }

    Код для получения аптайма приложения.

    Belz, 20 Августа 2019

    Комментарии (35)
  8. Java / Говнокод #25728

    +4

    1. 1
    Java говно

    3_15dar, 22 Июля 2019

    Комментарии (181)
  9. Java / Говнокод #25727

    +1

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    public static Date getMinDate(List<Date> dates) {
        Preconditions.checkArgument(dates != null && !dates.isEmpty(), "Dates list must be not null and not empty");
        dates.sort(Comparator.naturalOrder());
        return dates.get(0);
      }

    ну а че

    snml, 22 Июля 2019

    Комментарии (12)
  10. Java / Говнокод #25697

    +2

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    super(
                new TkWithHeaders(
                    new TkVersioned(
                        new TkMeasured(
                            new TkFlash(
                                new TkAppFallback(
                                    new TkAppAuth(
                                        new TkForward(
                                            new TkFork(
                                                new FkHost(
                                                    "relay.jare.io",
                                                    new TkFallback(
                                                        new TkRelay(base),
                                                        req -> new Opt.Single<>(
                                                            new RsWithType(
                                                                new RsWithBody(
                                                                    new RsWithStatus(req.code()),
                                                                    new Sprintf(

    Код вполне рабочего проекта

    Ray_Mints, 04 Июля 2019

    Комментарии (26)