print ("This program will calculate the Quadratic Formula (plus and minus.")
import math
# Formula for calculating the Quadratic Formula:
# QuadraticPlus = ( (-bravo) + math.sqrt((bravo**2)-(4*alpha*charlie)) / (2*alpha) )
# QuadraticMinus = ( (-bravo) - math.sqrt((bravo**2)-(4*alpha*charlie)) / (2*alpha) )
###########################################
# 1 function: solve for the Quadratic Formula plus and minus
# math.sqrt(x) - returns square root of "x"
# Function to solve for the Quadratic Formula
# Enter alpha, bravo and charlie variables
# QuadraticPlus = ( (-bravo) + math.sqrt((bravo**2)-(4*alpha*charlie)) / (2*alpha) )
# QuadraticMinus = ( (-bravo) - math.sqrt((bravo**2)-(4*alpha*charlie)) / (2*alpha) )
def SolveForQuadraticPlus():
print ("Solving for the Quadratic Formula (Plus).")
# Square root function: math.sqrt(x)
alpha = float(input("Enter the alpha variable. Cannot be 0! (eg: -1.25): ") )
bravo = float(input("Enter the bravo variable (eg: 4): ") )
charlie = float(input("Enter the charlie variable (eg: 3): ") )
twotimesalpha = 2*alpha
# print("twotimesalpha: ", twotimesalpha)
fouralphacharlie = 4*alpha*charlie
# print("fouralphacharlie: ", fouralphacharlie)
bravosquared = bravo**2
# print("bravosquared: ", bravosquared)
bravosquaredminusfouralphacharlie = (bravosquared)-(fouralphacharlie)
# print("bravosquaredminusfouralphacharlie: ", bravosquaredminusfouralphacharlie)
squarerootresult = math.sqrt(bravosquaredminusfouralphacharlie)
QuadraticPlus = ( (-bravo) + math.sqrt((bravo**2)-(4*alpha*charlie)) / (2*alpha) )
QuadraticPlus = ( ((-bravo) + squarerootresult ) / (2*alpha) )
QuadraticMinus = ( ((-bravo) - squarerootresult ) / (2*alpha) )
print("The Quadradric Plus is: ", QuadraticPlus)
print("The Quadradric Minus is: ", QuadraticMinus)
ContinueCalculations = "y"
# Check to see if the user wants to continue to calculate the Quadratic Formula
while (ContinueCalculations=="y"):
SolveForQuadraticPlus()
ContinueCalculations = input("Would like to do another calculation for the the Quadratic Formula? (y/n): ")
print("==================================")
print ("Thank you to www.MathsIsFun.com for assistance with this formula.")