Welcome to the Java Programming Forums

The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.

>> REGISTER NOW TO START POSTING

1. ## Create a java program to solve quadratic eqations

Solving a quadratic equation The program must have two methods quadraticEquationRoot1 which takes as input 3 doubles, representing a,b,c and returns the larger of the two roots and quadraticEquationRoot 2 which takes as input 3 doubles, representing a,b, and c (in that order) and returns the smaller of the two roots.

We assume that the numbers a,b,c are chosen so that the square root is never the square root of a negative number

I have the following written down so far. I am not sure on how to introduce the second method

public static void main(string args[]){

}

public static double quadraticEquationRoot1(int a, int b, int c) (){

}

if(Math.sqrt(Math.pow(b, 2) - 4*a*c) == 0)

{

return -b/(2*a);

}else

{

int root1, root2;

root1 = (-b + Math.sqrt(Math.pow(b, 2) - 4*a*c)) / (2*a);

root2 = (-b - Math.sqrt(Math.pow(b, 2) - 4*a*c)) / (2*a);

return Math.max(root1, root2);
}

}

2. ## Re: Create a java program to solve quadratic eqations

This thread has been cross posted here: