# how can I extract the double values of variables from the equation?

Page 1 of 1

## 3 Replies - 817 Views - Last Post: 25 April 2011 - 07:47 PMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'https://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=229285&amp;s=4a64cac45c89d1e8306ee8e62d31d9d5&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 AhmedElbatrawy

Reputation: 0
• Posts: 3
• Joined: 13-March 11

# how can I extract the double values of variables from the equation?

Posted 25 April 2011 - 07:09 PM

hello all :
I have a problem in extracting the double values and the negative values from the mathimatical equation
in my project I stored the equations in array of string so every index have one equation
I want to extract the values from this equation
like this :
array [0]= 2.2*x1+3*x2-4x3-3.8x4
I want to extract the values in the first array like { 2.2 , 3 , -4 , -3.8 }
and the second array { x1 , x2 , x3 , x4 }
hint : my project in the simplex method in lenear programming I need help plez
I work with java language

Is This A Good Question/Topic? 0

## Replies To: how can I extract the double values of variables from the equation?

### #2 macosxnerd101

• Games, Graphs, and Auctions

Reputation: 12316
• Posts: 45,416
• Joined: 27-December 08

## Re: how can I extract the double values of variables from the equation?

Posted 25 April 2011 - 07:14 PM

Moved to Java.

Take a look at the String split() method. You can split around the + and - signs, and then just parse out the coefficient from the x's.

### #3 AhmedElbatrawy

Reputation: 0
• Posts: 3
• Joined: 13-March 11

## Re: how can I extract the double values of variables from the equation?

Posted 25 April 2011 - 07:21 PM

frist I used this to read line by line from JTextarea

String s[] = area.getText().split("\n");;
for(int i = 0 ; i<s.length ;i++)
{
System.out.println("Array of"+i +"is "+ s[i]);

}

then I have a problem when I deals with other conditions (+ , - , . )
what shall I do ?

### #4 AhmedElbatrawy

Reputation: 0
• Posts: 3
• Joined: 13-March 11

## Re: how can I extract the double values of variables from the equation?

Posted 25 April 2011 - 07:47 PM