![]() |
String to strings? Help please
Hi guys, Im pretty new to Java so bare with me as I make a complete fool of myself. Im trying to start out by making a simple calculator, capable of the functions plus, minus, divide, multiply. I had no trouble doing this within eclipse, however turning it into a windowed program made it a lot harder for me.
The basic problem im having is using the method: String = JOptionPane.showInputDialog("text") Mine looks like this: Code:
inStr1 = JOptionPane.showInputDialog("Please Input an Equation\n" +A good chunk of the problematic area, As you can see I tried playing around with a few things but I am completely lost at this point lol, thanks in advance. Code:
import java.util.*; |
This isn't javascript, it's java. Moving to the Java forum.
Given the rules you have specified here, you can tokenize and cast the strings. Pulling from an array of String broken with a space is also sufficient. This is almost entirely correct. The problem is you cannot pull from String[x] as String is a datatype, not a variable. You need to pull from values[x] instead. Next to this, a try/catch should be used: PHP Code:
|
Hey, didn't notice I posted it in Java Script. Thought I had it in Java Forums. My bad and sorry for the inconvenience.
That was extremely helpful and I learned something new :] The calculator now works fine for everything- Aside from input errors. Two more questions I had though if someone could answer, I'll make a new thread for it though and link it here: http://www.codingforums.com/showthre...64#post1277864 |
| All times are GMT +1. The time now is 05:51 PM. |
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.