If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

String/Int variable in java?

OK, I am working on a calculator, and I would like it to be able to do algebra and more. However, I would also like it to show every step of the problem and the solution.

The problem is that I would need a variable. From my understanding, an int or double has to be of defined value before it can be used. So I thought the next best step would be to use a String for the equation an manipulate it that way.

Well, the problem is that this would take so much RAM and code I doubt it would be useful. Is there any way to go around this? Or am I forced to use Strings?

I thought about making a variable class that would extend double, but I am (again) not sure if that would work correctly.

this would output the answer and you could put a line above it that explains what you told the program to do to the varibles it took into the buffer

so for example you could have something like this above :

Code:

real = rr;
imaginary = ii;
public double magnitude() { // return the sq root of Complex number
system.out.println( "i told this hunk of crap to make the sqrt of a complex number using the Math.sqrt(real*real + imaginary*imaginary) function" );
return Math.sqrt(r*r + i*i);

you could devise a much more complicated system for this where when you told three calc to do something it would append that process to the output line of the line....but then you would have to add a string variable that made sense to each type of calculation that you would want your calc to be able to preform