r/javahelp • • Nov 22 '13

Can't figure out what I've done wrong with calculator program. Please help.

Had to do a calculator problem for my intro to computer science. Professor won't help much because there's so many people. Can someone take a look, spent about 10 hrs trying to figure it out. I know its something stupid but I'm really strugglin here. https://drive.google.com/file/d/0ByUS4XKjSuP9VFlSYThkRVR6ME0/edit?usp=sharing

0 Upvotes

7 comments sorted by

2

u/GaM_Ma Nov 22 '13

I think you confused this sub with /r/javascript, try posting there :)

1

u/virtyx Nov 22 '13

Well this is certainly the wrong subreddit since your code is JavaScript and this is help for Java (which is a very different language despite the very similar name).

That said, the easiest idea: throw alert()s into your totalFunction(), both for the arguments (g1...g4) and the outputs (what you return). Try and find if where the NaN appears.

1

u/gtobiast13 Nov 22 '13

sorry someone already told me

1

u/_jamil_ Nov 22 '13

throw alert()s

Don't do that. Instead use console.log() or console.error()

1

u/raki1 Nov 22 '13

Yep, definitely wrong subreddit. But still some words of advise: move your javascript to <script> tags and create some functions.

1

u/4forpengs Barista Nov 23 '13

neededSubreddit = thisSubreddit.concat("Script");