'''
Created on Jun 16, 2013

@author: Jared

This program asks the user for a, b, and c from the quadratic equation,
and then solves the equation for real roots. If the equation has complex
roots, then a message stating so is printed to the screen.

Python conversion of Arup's Java code
'''

from math import sqrt

def main():
        # Get the input from the user.
        a = float(input("Enter a from your quadratic equation.\n"))
        b = float(input("Enter b from your quadratic equation.\n"))
        c = float(input("Enter c from your quadratic equation.\n"))

        # Calculate the discriminant.
        discriminant = pow(b, 2) - 4 * a * c

        # Complex root case.
        if (discriminant < 0):
            print("Your quadratic has complex roots.")

        # Real root case.
        else:
            r1 = (-b + sqrt(discriminant)) / (2 * a)
            r2 = (-b - sqrt(discriminant)) / (2 * a)
     
            print("The roots to your quadratic are " + str(r1) + " and " + str(r2) + ".")
        
# runs main module on startup
if __name__ == "__main__":
    main()
