Hi I don't know if I am taking the wrong approach with this as I have just started to learn programming in the book I am teaching myself from it said how would you write the following arithmetic expression with it being the quadratic formula but only the plus part of it in the plus or minus..package javalearning; import java.util.Scanner; public class QuadraticFormula { public static void main(String[] args){ Scanner input = new Scanner(System.in); System.out.print("Enter value for B: "); double B = input.nextDouble(); System.out.print("Enter value for A: "); double A = input.nextDouble(); System.out.print("Enter value for C: "); double C = input.nextDouble(); double negativeOfB = -B; double bPowerOfTwo = Math.pow(B, 2); double squareRoot = Math.sqrt(bPowerOfTwo - (4 * A * C)); double Dividend = negativeOfB + squareRoot; double Divisor = 2 * A; double Answer = Dividend / Divisor; System.out.println("The answer to the Quadratic Formula where B is " + B + " A is " + A + " and C is " + C + " is " + Answer + "."); } }
The result for a problem I know the answer to is 5Any and all help is very appreciated Thank you ahead of time side note I am new to this so If i posted this in a wrong way please let me know and I will fix itrun: Enter value for B: -3 Enter value for A: -10 Enter value for C: 1 The answer to the Quadratic Formula where B is -3.0 A is -10.0 and C is 1.0 is -0.5. BUILD SUCCESSFUL (total time: 11 seconds)