Advertisement
calcpage

C5X1_QuadraticEquationTester.java

Nov 14th, 2011
336
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.82 KB | None | 0 0
  1. /**
  2. QuadraticEquationTester.java    MrG 2011.1024
  3. purpose:    find the roots of a quadratic equation
  4. required files: QuadraticEquationTester.java        main class
  5.         QuadraticEquation.java          derived class
  6. translator: javac QuadraticEquationTester.java
  7. interpreter:    java QuadraticEquationTester a b c
  8. */
  9.  
  10. public class QuadraticEquationTester
  11. {
  12.     public static void main(String[] args)
  13.     {
  14.         int a = Integer.parseInt(args[0]);
  15.         int b = Integer.parseInt(args[1]);
  16.         int c = Integer.parseInt(args[2]);
  17.         QuadraticEquation joey = new QuadraticEquation(a,b,c);
  18.         System.out.println("disc = " + joey.getDisc());
  19.         if(joey.hasSolutions())
  20.         {
  21.             System.out.println("root1 = " + joey.getRoot1());
  22.             System.out.println("root2 = " + joey.getRoot2());
  23.         }
  24.         else
  25.         {
  26.             System.out.println("The roots are complex conjugates!");
  27.         }
  28.     }
  29. }
  30.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement