hi ....
i have written a programm which solves the math equation :
x = -b +- square root of b ^ 2 - 4 (a)(c) all / 2(a)
programm is really short since am still a beginner
so heer it is :
import java.awt.*;
import java.applet.Applet;
public class MathEqu extends Applet
{
InputField inputBox1;
InputField inputBox2;
InputField inputBox3;
public void init() {
inputBox1 = new InputField(5);
inputBox2 = new InputField(5);
inputBox3 = new InputField(5);
inputBox1.initialise(0);
inputBox2.initialise(0);
inputBox3.initialise(0);
add(inputBox1);
add(inputBox2);
add(inputBox3);
repaint();
}
public void paint( Graphics g ) {
double a = inputBox1.toInt();
double b = inputBox2.toInt();
double c = inputBox3.toInt();
double first =((b*b)-4*(a)*(c))*1;
double x1=(b*(-1))+(Math.sqrt(first))/(2*a);
double x2=(b*(-1))-(Math.sqrt(first))/(2*a);
g.drawString( "answer is " + x1, 10, 50 );
g.drawString( "or answer is " + x2, 10, 70 );
}
public boolean action ( Event e, Object o ){
repaint();
return true;
}
}
any help with that will be great
thanx...