Results 1 to 2 of 2

Thread: String/Int variable in java?

  1. #1
    Senior Member
    Join Date
    Oct 2005
    Posts
    106

    Question 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.

    So I need a little guidance in this thing.

  2. #2
    Senior Member
    Join Date
    Sep 2003
    Posts
    101
    If I were you I would simply create another moduel to your program that converts your private variables and work into strings for output. Or you could just do something along the lines of this:

    Code:
     real = rr;
     imaginary = ii;
    
    
    public double magnitude() {       // return the sq root of Complex number
             return Math.sqrt(r*r + i*i);
    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

    http://www.antionline.com/showthread...hreadid=273394 (an example of a calc i did for complex numbers)
    chown -r us ./bases

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •