Results 1 to 13 of 13

Thread: how to convert a string with operands to an integer

Threaded View

  1. #1

    Thread Starter
    Frenzied Member System_Error's Avatar
    Join Date
    Apr 2004
    Posts
    1,111

    Resolved how to convert a string with operands to an integer

    I guess it's obvious I've been working on a Calculator. I got stumped pretty soon into the project. How can I get the String entered and then convert it to an int when it has operands? I've tried so many different ways:

    String s = textfield.getText();// were the text might be 1+1
    int i = integer.parseInt(s);

    I thought if there was no spaces between the 1 and + it would work...

    The only sensible way I can think of is using a string tokenizer. But how would you append the operand to the numbers?



    <Moderator added green checkmark in the first thread>
    Last edited by NoteMe; Feb 17th, 2005 at 07:21 AM.

Posting Permissions

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



Click Here to Expand Forum to Full Width