This is my first post, so hopefully I can give enough information. I am running windows xp, using jGrasp to write code. I need to make a calculator in which the user inputs 2 floating point numbers and an operation, with and output of the answer with the original equation. I think I need to use the split function, however I dont know what to do once it is split. Here is what I have so far-
import javax.swing.*;
import java.awt.*;
import java.util.*;
public class Calculator{
public static void main (String[] args){
String inputString = JOptionPane.sho wInputDialog("b lah blah");
String[] result = inputString.spl it("//s");
for (int x=0; x<result.length ; x++)
}
}
I'm new, if you can't tell, so im sorry if this is extremely elementary. In my mind, I would want to give each part of the string a name or letter, then use those for the rest of the code. I dont know if this is possible. Ex- input- "2 + 1" would give a=2 b=+ c=1, then I could go about using if statements to separate the operations (I need +-/* and % (remainder)). Thanks! Max
					import javax.swing.*;
import java.awt.*;
import java.util.*;
public class Calculator{
public static void main (String[] args){
String inputString = JOptionPane.sho wInputDialog("b lah blah");
String[] result = inputString.spl it("//s");
for (int x=0; x<result.length ; x++)
}
}
I'm new, if you can't tell, so im sorry if this is extremely elementary. In my mind, I would want to give each part of the string a name or letter, then use those for the rest of the code. I dont know if this is possible. Ex- input- "2 + 1" would give a=2 b=+ c=1, then I could go about using if statements to separate the operations (I need +-/* and % (remainder)). Thanks! Max
Comment