Thomas VanHuy

Greenhorn
+ Follow
since Jan 03, 2013
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Thomas VanHuy

Joanne Neal wrote:

Thomas VanHuy wrote:I can enter the operation, then I click "ok" to go to the next box but my program closes after clicking "ok".


Does it actually close or does it just sit there apparently doing nothing ?
On line 20 the program is waiting for you to input something on the command line. You don't need to do this. The name variable on line 18 contains the value you typed into the dialog. Get rid of all the Scanner objects you create and it should work fine.

Edit: You will of course need to convert the values of the option and option2 variables to doubles before you can use them in any arithmetic. You can use the Double.parseDouble method to do this.



Is this what you meant?



Because now after entering the operation I get this exception: Exception in thread "main" java.lang.NullPointerException
at rekenmachine1.main(rekenmachine1.java:20)
11 years ago
Hi, I really wouldn't know how to fix the problem I'm experiencing, I hope you guys at Javaranch can help me.

What happens when I run the code: the JOptionPane dialog that lets the user choose the operation opens, I can enter the operation, then I click "ok" to go to the next box but my program closes after clicking "ok".

I've tried seeing what could be wrong in my code but I really can't spot what I did wrong.




Thanks to anyone willing to take the time to help me out.
11 years ago