Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Geek Culture / Java error that I just can't get my head around!

Author
Message
Dark Frager
14
Years of Service
User Offline
Joined: 16th Mar 2010
Location: The Void.
Posted: 14th Sep 2012 21:39 Edited at: 14th Sep 2012 21:40
Hello.

Because I plan on doing something with Java (and because it has the only editor that doesn't throw up weird errors at me) I decided to learn it. I've watched few tutorials and decided to make a small quiz just to see what I can do with what I've already learned. The thing is , the program I have wrote is supposed to say "Yes it is correct" when the answer is "2" but it always says the opposite "Nope." I have searched through numerous forums and even the documentation, all which help, but bring me back to the same issue.

Here is my code:



If anyone programs in Java and could help me with this issue it would be appreciated.

Thank you!!

Oh come on. We're trying to talk with sigs here and you rudely interrupt.
Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 14th Sep 2012 21:47
I think you should be doing this:



"everyone forgets a semi-colon sometimes." - Phaelax
Dark Frager
14
Years of Service
User Offline
Joined: 16th Mar 2010
Location: The Void.
Posted: 14th Sep 2012 22:05
Thanks for your response, it works, but after entering the answer, this comes up in the console:



Oh come on. We're trying to talk with sigs here and you rudely interrupt.
Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 14th Sep 2012 22:08
Are you still doing 'question.close()'? I don't think it's necessary. Keep in mind I haven't used Java in a couple of years.

"everyone forgets a semi-colon sometimes." - Phaelax
Dark Frager
14
Years of Service
User Offline
Joined: 16th Mar 2010
Location: The Void.
Posted: 14th Sep 2012 22:10 Edited at: 14th Sep 2012 22:13
Nah, it has to be there. Otherwise it says "Resource leak: "question is never closed" and when you enter the answer and press enter nothing happens. Thanks for helping anyway

edit: OH MY GOD. I got it work. I just had to delete question.nextDouble(); since double answer = question.nextDouble(); was there
Thanks for the help.

Mods can lock if they wish.

Oh come on. We're trying to talk with sigs here and you rudely interrupt.

Login to post a reply

Server time is: 2024-05-06 19:04:56
Your offset time is: 2024-05-06 19:04:56