/* * =================================================================== * Quadratic.java : Compute roots of quadratic equation having complex * coefficients. * * Written By : Mark Austin May 1998 * =================================================================== */ import java.lang.Math; import java.util.*; import java.io.*; public class Quadratic { public static void main( String args[] ) { Complex cA = new Complex(); Complex cB = new Complex(); Complex cC = new Complex(); Complex cRoot1, cRoot2; String sLine; // Print Welcome Message System.out.println("Welcome to The Quadratic Equation Solver"); System.out.println("----------------------------------------"); // Prompt User for Coefficients in Quadratic Equation... System.out.println("Please Enter coefficients for equation"); System.out.println("a.x^2 + b.x + c"); // Get Coefficient cA .... ...... fill in the missing details here .... // Get Coefficient cB .... ...... fill in the missing details here .... // Get Coefficient cC .... ...... fill in the missing details here .... // Print details of Quadratic Equation to screen ... ...... fill in the missing details here : you should use the toString() method in Class complex.... // Check for Degenerate roots (i.e., cA and cB both equal to zero). ...... fill in the missing details here .... // Compute the matrix discriminant ..... ...... fill in the missing details here : you should use the Mult(), Sub() and Scale() methods in Class complex..... // Compute and print roots to equation ..... ...... fill in the missing details here .... // Check that roots of equation are correct .... ...... fill in the missing details here .... // Verify that root1 is correct .... ...... fill in the missing details here .... // Verify that root2 is correct .... ...... fill in the missing details here .... } /* * =========================================================== * Method keyboardInput() : Get line of input from keyboard * * Input : None. * Output : String sLine -- character string of keyboard input * =========================================================== */ static String keyboardInput() { String sLine; DataInputStream in = new DataInputStream(System.in); try{ sLine = in.readLine(); return sLine; } catch (Exception e){ return "error"; } } }