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

Question #46282
Java programming.
square root.

X = -b± √b2 – 4ac
2a
Find x
1
Expert's answer
2014-09-24T12:36:41-0400
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!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS