Hay guys... Anyone knows how to solve this equation?Code:public class Equation {
public void main(String [] args){
String equation="3x=6";
// HMMMMMMMMM?
System.out.println(x); //x=2 <---how
}
}
Printable View
Hay guys... Anyone knows how to solve this equation?Code:public class Equation {
public void main(String [] args){
String equation="3x=6";
// HMMMMMMMMM?
System.out.println(x); //x=2 <---how
}
}
You could rewrite your code to this...
System.out.println("x= " + (6 / 3));
Or, if you are wanting to pass in a string and have it spit out a result, you'll need to create a String parser to do the work for you. There might be an API out there that someone has written, so do some googling and you might get lucky!