please help.. this my importtant project..!!!!!

please help.. this my importtant project..!!!!!

Consider the Algebra: Solving quadratic equations. The two roots of a quadratic equation ax2 + bx + c = 0 can be obtained using the formula: ???????????1= ?????+?????2??4??????2??? ???????????2=????????????2??4??????2??? b2 ?? 4ac is called the discriminant of the quadratic equation. If it is positive, the equation has two real roots. If it is zero, the equation has one root. If it is negative, the equatation has no real roots. Figure 1:QuadraticEquation Class Diagram a) Implement class QuadraticEquation based on above scenario and Figure 1. b) Write a Java test program that creates object with a=3, b=4 and c=1. Display the result based on discriminant. The program will prompt the user to enter values for a, b, and c and displays the result based on discriminant. If the discriminat is positive, display two roots. If discriminant is 0, display one root. Otherwise, display ??The equation has no real roots??.

View Answers

November 21, 2012 at 1:06 PM

Here is a code of finding roots of quadratic equations.

class QuadraticEquation
public static void main(String[]args){
double a=3;
double b=4;
double c=1;

double eq=b*b-4*a*c;
double r1= -b+Math.sqrt(eq);
double r2= -b-Math.sqrt(eq);
double Root1=r1/2*a;
double Root2=r2/2*a;
System.out.println("Root 1 ="+Root1);
System.out.println("Root 2 ="+Root2);

Related Tutorials/Questions & Answers: