Java programming.
square root.
X = -b± √b2 – 4ac
2a
Find x
import java.util.Scanner;
public classSquareRoot {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.print("Input a:");
int a = input.nextInt();
System.out.print("Input b:");
int b = input.nextInt();
System.out.print("Input c:");
int c = input.nextInt();
double x1 = (-b + Math.sqrt(b * b - 4 *a * c)) / (2 * a);
double x2 = (-b - Math.sqrt(b * b - 4 *a * c)) / (2 * a);
System.out.println("First root is" + x1 + " Second root: " + x2);
}
}
Need a fast expert's response?
Submit order
and get a quick answer at the best price
for any assignment or question with DETAILED EXPLANATIONS!
Learn more about our help with Assignments:
JavaJSPJSF