3 Replies - 602 Views - Last Post: 25 April 2011 - 07:47 PM Rate Topic: -----

#1 AhmedElbatrawy  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • 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  Icon User is offline

  • Self-Trained Economist
  • member icon




Reputation: 10825
  • View blog
  • Posts: 40,363
  • 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.
Was This Post Helpful? 0
  • +
  • -

#3 AhmedElbatrawy  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • 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 ?
Was This Post Helpful? 0
  • +
  • -

#4 AhmedElbatrawy  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • 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

I need help please
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1