I have this code but i would like it to ask the user to enter the Equation then the program will sense what Operator(+/*-) they want. A sample input would be 7+8 i want the program to be able to detect the sign. How would i go about doing this?
You'd have to parse the character sequence of the equation, one character at a time, and then determine the number of variables and the operations the equation involves. Since the length of the equation may vary ("7+8" , "7+8-(6+11)*5" etc), your equation string parser would have to be recursive, so that it can penetrate and parse any number of brackets, sequence of operations, number of required variables etc. .
When parsing, you'd have to read a character, determine if it's a digit (in which case it would have to be stored as a variable), an operator (in which case it determines the operation to be applied to the previously read number), a bracket (in which case the content of the bracket should be calculated independently of the operators applied outside of the bracket, probably by means of a recursive function that returns a numerical value -- perhaps a double). Also make sure to calculate multiplication and division operations prior to addition and subtraction operations if no brackets are specified, etc. All this should be done by parsing the equation character-by-character and determining the series of operations. The parsing continues until the end of the string is reached, in which case you may want to perform some checks to make sure that no open brackets or unhandled operators remained without being used (which may be due to incomplete or erroneous user input, like "7-(", "7+", "7+*" etc), before outputting a result.