title: Solving quadratic equation USING METHODS, java
body: <p>I have a java program written for solving the quadratic equation but the assignment requires me to have methods for each of the tasks: displaying the equation, determining if the equation has real solutions, calculating a solution, and displaying the solutions if they exist. I have methods for everything except for checking if the solutions are real except my methods are saying that they are undefined. Can someone please help me format my methods, I don't quite know how to implement them? here is the code I have thus far:</p>
  
  <pre><code>import java.util.Scanner;
  public class QuadraticFormula {
  
  public static void main(String[] args)
  {
      //Creating scanner and variables
      Scanner s = new Scanner(System.in);
      System.out.println("Insert value for a: ");
      double a = Double.parseDouble(s.nextLine());
      System.out.println("Insert value for b: ");
      double b = Double.parseDouble(s.nextLine());
      System.out.println("Insert value for c: ");
      double c = Double.parseDouble(s.nextLine());
  
      //Display format for negatives
      displayEquation(double a, double b, double c);{
      if (b &gt; 0 &amp;&amp; c &gt; 0 ){
          System.out.println(a + "x^2 + " + b + "x + " + c + " =0");}
      if (b &lt; 0 &amp;&amp; c &gt; 0 ){
          System.out.println(a + "x^2 " + b + "x + " + c + " =0");}
      if (b &gt; 0 &amp;&amp; c &lt; 0 ){
          System.out.println(a + "x^2 + " + b + "x " + c + " =0");}
      if (b &lt; 0 &amp;&amp; c &lt; 0 ){
          System.out.println(a + "x^2 " + b + "x " + c + " =0");}
      s.close();
      }
      //The work/formula
      private static double calculateSolution(double a, double b, double c); 
      {
      double answer1 = (-b + Math.sqrt(Math.pow(b, 2) - (4 * a * c))) / (2 * a);
      return answer1;
      }
  
      private static double calculateSolution(double a, double b, double c); 
      {
      double answer2 = (-b - Math.sqrt(Math.pow(b, 2) - (4 * a * c))) / (2 * a);
      return answer2;
      }
      //Display results and check if the solution is imaginary (real or not)
      private static void displaySolutions(double answer1, double answer2); {
      if (Double.isNaN(answer1) || Double.isNaN(answer2))
      {
          System.out.println("Answer contains imaginary numbers");
      } else System.out.println("The values are: " + answer1 + ", " + answer2);
  }
  }
  </code></pre>
  
  <p>}</p>