954,506 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

programming Help needed

ok im trying to make a program for solving square equations by the general formula
but for some reason i cannot get it to solve the equation
so if anyone can help me
this is my code:

va= Integer.parseInt(a.getText());
vb= Integer.parseInt(b.getText());
vc= Integer.parseInt(c.getText());
vac=(4*va*vc);
vbc=(2*vb*vb);
vac2= (2*va);
vb2=(-1*vb);
raiz = Math.sqrt(vbc-vac);

vx1= ((vb2+raiz) / vac2);
vx2= ((vb2-raiz) / vac2);

x1p=String.valueOf(vx1);
x2p=String.valueOf(vx2);

x1.setText(x1p);
x2.setText(x2p);

cocotugo
Newbie Poster
2 posts since Jun 2008
Reputation Points: 10
Solved Threads: 0
 

Well, what problems are you having? What errors if any? Posting several lines of abbreviated variables and equations and saying "it's not right" is a bit vague.

Ezzaral
Posting Genius
Moderator
15,986 posts since May 2007
Reputation Points: 3,250
Solved Threads: 847
 
vac=(4*va*vc);
vbc=(2*vb*vb);
....
raiz = Math.sqrt(vbc-vac);


The correct formula is b*b - 4*a*c. You write: vbc-vac =2*vb*vb - 4*va*vc

javaAddict
Nearly a Senior Poster
Team Colleague
3,329 posts since Dec 2007
Reputation Points: 1,014
Solved Threads: 448
 

thats right
thenk you javaAddict

cocotugo
Newbie Poster
2 posts since Jun 2008
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You