# Answer to Question #46282 in Java | JSP | JSF for Fel

Question #46282

Java programming.

square root.

X = -b± √b2 – 4ac

2a

Find x

square root.

X = -b± √b2 – 4ac

2a

Find x

Expert's answer

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);

}

}

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);

}

}

## Comments

## Leave a comment