Hi,

I got my quadratic equations program to run calculating the roots, but I can't seem to the following:

1. Print the quadratic equation from the coefficents.

//Note: I tired doing that by just saying System.out.println("The equation is: "+a.b^2 + b.x+c") but it didn't compile on my Command Prompt Window.

2. Use if statements to deal with the nature of the roots. (discriminants)

//Note: I tried but was unsuccessful in this part. I saw examples online but I don't know how to incorporate it, I never learned try/catch yet so I can't use that in my program.

Thanks coders who help me,

Coder752

Here's my code:
import java.util.Scanner;

public class Quadratic{
public static void main(String[] args){

System.out.println("Enter three coefficients");
Scanner sc = new Scanner(System.in);
double a = sc.nextDouble();
double b = sc.nextDouble();
double c = sc.nextDouble();
double root1= (-b + Math.sqrt( b*b - 4*a*c ) )/ (2*a);
double root2= (-b - Math.sqrt( b*b - 4*a*c ) )/ (2*a);
System.out.println("The roots are: "+ root1);
System.out.println("and: " + root2);
//System.out.println("The equation is: ");
//System.out.println(" +a.x^2 + b.x +c");

}
}