Welcome to the Java Programming Forums

The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.

>> REGISTER NOW TO START POSTING

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 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;
B + " A is " + A + " and C is " + C + " is " + Answer + ".");

}
}```

The result for a problem I know the answer to is 5
```run:
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)```
Any 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 it