I have just finished two quarters of
Java programming in college. I thought I'd kill two birds with one stone : I could continue improving my Java skills by writing programs which pertain to the upcoming quarter of Calculus (the multi-variable kind). I've got some spare time, so I started writing a program to do single-variable differentiation and integration.
Currently, I have a really nice GUI in which I enter a function in a JTextArea on the left, I select a JRadioCheckButton for "dy/dx" or "integrate" in the middle, and a JTextArea on the right side gets the solution after the Calculus class gets done. The Calculus class takes the expression in
String form, iterates through it, and puts coefficients, variables, exponents, trig functions, and ln each into indexes in an ArrayList<String>. If "dy/dx" was selected, my Calculus.java can successfully apply the Power Rule (if the exponent is positive). The Chain Rule...Implicit Differentiation...all of Integral Calculus...I think I'm getting a headache...
In a nutshell, my program looks like a hot mess of nested ifs and a 50-line Switch statement just to get the expression into the ArrayList<String>. It's
Rube Goldberg: Java Programmer.
My goals with this project, as I mentioned, are to use Java practice as a way of reinforcing what I learn during the course. Between now and when the quarter begins, I want a program which can do all or most of what I've learned thus far, and then I can mix in the stuff I learn as I learn it.
So...what should my strategy be? How do I use these libraries that are out there such as Apache Commons? Where I can find discussion of similar endeavors, TreeNodes seem to be the preferred tool; why is that?
I would definitely appreciate any help I can get on this. And, if anyone's in the Seattle area, I'll buy ya a beer sometime!