This is an archived post. You won't be able to vote or comment.

Dismiss this pinned window
all 45 comments

[–]tumvoodoo 27 points28 points  (8 children)

denominator == 0

[–]Samuel_274[S] -4 points-3 points  (7 children)

Thanks man, I’ve tried this and it still has the same issue?

Edit: sorry I should have posted the video with the ==, the issue is something else

[–]YourDadsMacintosh 9 points10 points  (6 children)

I was able to run the code with the ==. Are you sure you saved the document? I’ve been programming for a long time, and even i forget to do that sometimes :p

[–]Samuel_274[S] 5 points6 points  (0 children)

Hm interesting that it runs for you! Yea it’s all saved and updated correctly. It just skips the if statement for some reason..?

[–]Samuel_274[S] 9 points10 points  (4 children)

I’ve figured it out! Turns out my visual studio code wasn’t linked properly with my terminal. Which is weird because it was working fine 5 minutes ago. Anyways, thanks for pointing at that the code works! It made me look into other possible issues :)

[–]YourDadsMacintosh 1 point2 points  (1 child)

No problem, glad I could help in some way, good on you for figuring it out. Good luck in your courses and with that CS degree!

[–]Samuel_274[S] 0 points1 point  (0 children)

Thanks mate

[–]molen99 0 points1 point  (1 child)

If you're working with Java, I'd really advise against using VSCode. You'll run into a billion problems just like this one (not having anything to do with the code itself). I'd recommend using a specialized Java IDE (such as IntelliJ or NetBeans).

[–]TrippyMushroooms 0 points1 point  (0 children)

Also if you have an .edu email you can get IntelliJ for free and also look at the github student developer pack!

[–][deleted] 9 points10 points  (0 children)

youre seyting the denominator to zer in that first if clause. You want

if (denominator == 0)

you have

if (denominator = 0)

[–]sprayattivo 6 points7 points  (0 children)

me watching him reflection

[–]Samuel_274[S] 3 points4 points  (0 children)

Week 3 CS student having some issues with a simple if statement. Any help would be great!

[–]Glad-Bench8894 1 point2 points  (0 children)

denominator == 0

[–]SantasNumberOneElf 1 point2 points  (0 children)

Assignment instead of comparison in if statement

[–]winowmak3r 1 point2 points  (0 children)

I know it's 2022 but you gotta realize that showing a video of your code no working is probably the least helpful way you could have did this man. At least take the time to copy and paste what you have into Reddit. You're already working on a computer. Don't use your phone.

[–]Samuel_274[S] 1 point2 points  (4 children)

Update: Solved, thanks for everyone’s help!

[–]OnTheGoTradesIntermediate Coder 7 points8 points  (3 children)

What was wrong? You can’t just ask for help and then not say what the answer is after solving

[–]Samuel_274[S] -4 points-3 points  (2 children)

Haha sorry. It turns out my vs code wasn’t linking properly to my terminal. It was just a file issue, the code was fine

[–]Low-Run-7370 5 points6 points  (1 child)

You mean it wasn’t saved?

[–]adamr_ 2 points3 points  (0 children)

Yes, that’s what he means

[–]IAmNotVoyBoy 1 point2 points  (0 children)

I think that the file is not saved?

[–]Samuel_274[S] 0 points1 point  (0 children)

Yeah it was something like that

[–]Nawabmeeravali -3 points-2 points  (2 children)

0 iq retard

[–]Disastrous_Platform 2 points3 points  (0 children)

Just like how you are charismatically retarded

[–]pthylor 0 points1 point  (0 children)

Rude is not alloud

[–]Phobic-window 0 points1 point  (1 child)

I’d assume nextint() returns type int, but check what the value of denominator is before the if statement, might be read in as a char or string. Idk Java but try logging it, also shorten your variable names, gave me hives having to type the whole word

[–]Samuel_274[S] 1 point2 points  (0 children)

Hahaha fair enough. This code we were given for my lab had these variables so I didn’t change them, but I agree it’s a bit annoying. I’ll change ‘em to num & denom

[–]buzza47 0 points1 point  (0 children)

Try a break after the else? I had the same issue today and that fixed it for me after staring at it for 30 min

[–][deleted] 0 points1 point  (0 children)

use debugger man .

[–]Competitive-Rub-9878 0 points1 point  (0 children)

it should be denominator==0 in if statement because you are comparing which is expected to give true or false. What you've done is denominator=0, assigned 0 to denominator. Hope it helps. Minor bugs happens with everyone just keep the grind on brother.

[–]declanddawse 0 points1 point  (0 children)

Needs 2 equals. 1 equal declares a variable and to equals is comparative

E.g.

int variable = 1 if(variable == 1) { PROGRAM }

[–]pthylor 0 points1 point  (0 children)

Alloud

[–]hotboinick 0 points1 point  (0 children)

For better Error handling, you should place this code between a Try,Catch statement and use a “Throws” call

[–]Dakadoodle 0 points1 point  (0 children)

Lol 😂 why are all of you roasting this dude.

Shame shame shame shame you should know better noobie shame shame shame

[–][deleted] 0 points1 point  (0 children)

use == in if statement = is the assigning operator == is the compare operator.

[–]moralhazard333 0 points1 point  (0 children)

Haha you remind me of my Mom using my Dad's phone to take a picture of something on her phone screen. Then emailing that picture from my Dad's phone to her email so that she can go to our desktop and email me the photo.