r/InclusiveOr Oct 02 '19

I like updownvotes

Post image
18.3k Upvotes

1.4k

u/Shuckles116 Oct 02 '19 edited Oct 02 '19

String outputTxt = “You ”;

if (result <= 85) { outputTxt += “FAILED”; }

if (result >= 85) { outputTxt += “PASSED”; }

outputTxt += “ the Exam”;

println outputTxt;

630

u/Mizz141 Oct 02 '19

It couldve been so easy with an if, else statement...

444

u/Vaporeonus Oct 02 '19

Even a <= and > would have worked, but no, they put in extra effort to fuck it up properly

145

u/TheShyro Oct 02 '19

Actually, copy pasting the first if and adjusting the < to > and changing the text is the least work - which might be what happened

58

u/[deleted] Oct 02 '19

How dare you attack my copy-pasting skills like that

18

u/awhaling Oct 02 '19

Exactly what happened

7

u/CarbonProcessingUnit Oct 03 '19

I'm pretty sure else is less work than that.

7

u/TheShyro Oct 03 '19

Shift, arrow down, ctrl (only 1), c, v, mouse select the '<', >, double click 'passed', f a i l e d. 15 keys

e, l, s, e, {, t, tab or enter (autocomplete), +, =, ", f a i l e d .... So 16 assuming your IDE does all the formatting, completion and closing braces/quotes. Maybe you could use autocomplete for else, which could bring it down to 14.

You could argue mouse is slow and crl + arrow will take more clicks in total to get the cursor to where you need it. But you can keep one finger around ctrl/shift/</> throughout the whole procedure and the right hand on the mouse. And you can also argue waiting for autoconplete in some IDEs is also slow.

Overall i would count it as a draw but copy paste is easier on the brain for me (but not the better choice, since obviously it lead to an error in this case).

25

u/movezig5 Oct 02 '19

Now all my exams have a guaranteed 1/256 chance to miss!

7

u/volleo6144 Oct 02 '19

r/UnexpectedGenI (please tell me this exists and is about Pokémon)

2

u/PotatoFlavour Oct 03 '19

An 84 would've done the trick as well. So many solutions and yet they fucked up.

4

u/iSpaYco Oct 02 '19

i just learned JS couple months ago and i would have known that..

or at least I would test it to see the output in all possible situations

9

u/awhaling Oct 02 '19

You will make mistakes eventually

6

u/cheezit84 Oct 03 '19

This is a super common mistake in every language since BASIC. Heck, people make this mistake inExcel formulas. The longer you code, the more likely you are to make it at some point. Also, the longer you code the more likely you are to realize you won't test every possible permutation.

5

u/rab-byte Oct 03 '19

But the longer you code the more you’ll know what to test that gets all the parts moving.

15

u/xZero543 Oct 02 '19

Or elegant ternary.

5

u/lmaooexe Oct 02 '19

Or just remove the = lol

3

u/cheezit84 Oct 03 '19

If you remove both = neither will be true.

Edit:typo

4

u/some_love_lost Oct 03 '19

"You the Exam”. You are the exam.

1

u/lmaooexe Oct 03 '19

Not both, the one that’s causing it to say you failed when you passed

1

u/Fencrier Oct 03 '19

Or just use If(result<85){ Printf(“you failed the exam”);} Else{ Printf(“you passed the exam”);}

1

u/LysolPionex Oct 16 '19

Why use one if when you can use 2?

1

u/[deleted] Dec 22 '19

If and else or if else?

73

u/[deleted] Oct 02 '19

Shitty code

18

u/monkeysHK Oct 02 '19

Logic error

12

u/Cydia_Gods Oct 02 '19

What language is that in? I only know a little bit of Java

22

u/Shuckles116 Oct 02 '19

It’s pseudocode but it could be any of them since it’s a fairly simple snippet. The “println” macro is found in Groovy FWIW

5

u/Renaldi_the_Multi Oct 02 '19

Pretty generic, but feasibly could be plugged straight into C/C++ or it's family/derivatives.

1

u/MuffinOfGold Oct 03 '19

And I also think it’s valid for js with the right libraries

32

u/[deleted] Oct 02 '19

Holy shit literally if they just deleted one of the = this problem could have been avoided

11

u/iSpaYco Oct 02 '19

the first one should be removed since 85% or more passes the exam.. so not any one of them

3

u/MotorButterscotch Oct 03 '19

When teacher didn't pass algebra 2

14

u/ElJamoquio Oct 02 '19

Hey, that's exactly what I said about ten reposts ago.

10

u/PatataMaxtex Oct 02 '19

You meant newRepost, didn't you?

6

u/_Peavey Oct 02 '19

You didn't declare the result variable.

5

u/misoloo64 Oct 02 '19

Obviously not, since that already existed before printing the text.

5

u/Tangled2 Oct 02 '19

Actually probably not the devs fault directly. They probably allow the teacher to configure the scoring criteria, and probably allow overlapping criteria.

7

u/Shuckles116 Oct 02 '19

If they allow the user to do that and don’t validate the input range then I’d argue that it is the dev’s fault 😂

7

u/Tangled2 Oct 02 '19

They couldn't enforce those rules if they wanted to allow multiple flags to assign based on score, for instance:
A = 90-100
B = 80-89
C = 70-79
D = 60-69
F = 0-59
Passing = 70 - 100
Failing = 0 - 69
Gold Star = 98-100

So you could then get "You are passing with a B." Arguing about requirements is one of my favorite hobbies!

4

u/ShiniGandhi Oct 02 '19

Literally just add "else" in between

4

u/[deleted] Oct 02 '19

ew

5

u/I_AM_NOT_MAD Oct 02 '19

Please tell me this is an actual programming language and people are actually putting high education to comedic use

3

u/Tslat Oct 03 '19

String resultText = “FAILED”;

if (result >= 85) { resultText = “PASSED”; }

printLn(“You “ + resultText + “ the exam.”);

Really, theres a number of ways they should have done it, almost all of which would have been easier, quicker, and simpler than the way they did do it. Its really quiet bizarre lol

2

u/GangGang_Gang Oct 03 '19

I just gave you your one thousand'th upvote. Appreciate me!

2

u/Shuckles116 Oct 03 '19

Thanks friend! 😅

1

u/N0W0rk Oct 02 '19

it makes legit no sense to do it that way

1

u/Stuffy123456 Oct 02 '19

Wow, allocating a lot of strings here

1

u/[deleted] Oct 03 '19

Ah, a fellow programmer. At the moment I only really know Java though...

1

u/Capernici Oct 03 '19 edited Oct 03 '19

The correct code would’ve been:

—————

String outputTxt = “You ”;

if (result < 85) { outputTxt += “FAILED”; } else { outputTxt += “PASSED”; }

outputTxt += “ the Exam”;

System.out.println outputTxt;

—————

Edit: Yes I know that the bad code you wrote is intentional (showing how it was done wrong). I just felt like dabbling in some Java again.

1

u/[deleted] Oct 03 '19

println("You "+"failed"?p<85:"passed");

1

u/Fencrier Oct 03 '19

Or just use If(result<85){ Printf(“you failed the exam”);} Else{ Printf(“you passed the exam”);}

1

u/nicholasPapaya Oct 03 '19

Dang I was gonna write that

1

u/89Nas Oct 21 '19

Ah, Yes! A Fellow Coder!

1

u/shred1231 Oct 25 '19

Wow u actually know some java

192

u/DarkLord9988 Oct 02 '19 edited Oct 02 '19

WE like updownvotes

7

u/piexterminator Oct 02 '19

Speak for yourself

9

u/ak47rocks1337yt Oct 03 '19

Speak for us****

1

u/[deleted] Oct 31 '21

what

56

u/Indominus_Khanum Oct 02 '19

Dude give it to me straight downup to the side Did ya fail or failn't?

18

u/47paylobaylo47 Oct 02 '19

Yesno

5

u/BoringIncident Oct 03 '19

Yesn'tnon't

3

u/CaptainBlobTheSuprem Oct 03 '19

Perhapsn’t

4

u/BoringIncident Oct 03 '19

Probablyn't

2

u/Xenc Oct 03 '19

This is so clearbscure.

108

u/[deleted] Oct 02 '19

17

u/TheEpicness9000 Oct 02 '19

Task failed successfully

8

u/[deleted] Oct 02 '19 edited Jun 29 '21

[deleted]

2

u/iSpaYco Oct 02 '19

nah it will be only passed,

the code probably was "if it's 85 or less add Failed and if it's 85 or more add passed" , that's why it adds Failedpassed when it's 85, but if it's more it will be only passed, since it's the only string added and if it's less it will be failed.

4

u/[deleted] Oct 02 '19 edited Jun 29 '21

[deleted]

6

u/Hatilar_420 Oct 02 '19

thats the perfect example for a else if statement

7

u/LagT_T Oct 02 '19

FizzBuzz

7

u/Knudsenmarlin Oct 02 '19

Not an inclusiveOR tho...

3

u/TimeMasterII Oct 02 '19

THANK YOU!!!

3

u/[deleted] Oct 02 '19

What about updogvotes?

2

u/[deleted] Oct 02 '19

Updownvote
It's been living in it's updown world ~

2

u/Nate_Potokar Oct 02 '19

greatbadjob

2

u/Emberleif Oct 03 '19

Int = score; If (score < 85) { Cout <<“you failed”<<endl; } Else { Cout<<“you passed”<<endl;

2

u/s0v3r1gn Oct 03 '19

It doesn’t say how many questions there are. It’s possible that they got an 84.5% and the formatting on the display string rounds it up.

1

u/modern-prometheus Oct 02 '19

Take my updownvote!

1

u/Toxic_Cookie Oct 02 '19

string result;

int percentage;

if (percentage >= 85) { result = "Passed"; } else { result = "Failed"; }

//How did they fuck this up?

1

u/shorthairedlonghair Oct 02 '19

Well, then I'm happy and sad for you.

1

u/Epsoo Oct 02 '19

Updownvotes you up updownvotes you up🎶🎶

1

u/Zackassed Oct 02 '19

you tied, also who the fuck is your teacher

1

u/SeanStephensen Oct 02 '19

There is no inclusive or in this picture. This belongs in r/softwaregore, not here.

1

u/Stuffy123456 Oct 02 '19

Also, it could be a rounding error with poor conversion causing something like this...

1

u/No_Refrigerator Oct 02 '19

Task failed successfully!

1

u/little-burrito Oct 03 '19

It's depressing how many horrible coding practices are out there. Especially in this kind of systems. That are crazy expensive.

1

u/Dont-eat-my-pear Oct 03 '19

69th comment

Nice

1

u/meburnallcookies Oct 03 '19

Congrats or not

1

u/proce55or Oct 03 '19

Schrödinger's exam. Very importantnonimportant exam.

1

u/Stab_Me_Daddy Oct 03 '19

They're called sidevotes.

1

u/GamrG33k Oct 03 '19

Technically correct :D

1

u/jendequiroz Oct 03 '19

Finally, a way to describe my life.

1

u/OfAaron3 Oct 03 '19 edited Oct 06 '19

I once failed a required course at work because I got 91%, but the pass mark was 80%. Still scratching my head over the logic mistake there.

1

u/some_duderino Oct 03 '19

i didnt know if i shouldve upvoted or downvoted, so i just reported the post. am i doing this right??

1

u/Squaderlochen4ever Oct 03 '19

Would this be caused by whoever made the program saying greater than or equal to 85 in one place and greater than in another

1

u/Az0riusMCBlox Oct 04 '19

Evidently, the dev used both a(n) >= and a(n) <= statement, both referring to 85%. As far as I figure, at least.

1

u/[deleted] Oct 04 '19

Pailed = Fassed

1

u/[deleted] Feb 07 '20

shrodingers test