forked from dharmanshu1921/Java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBhaskForm.java
More file actions
24 lines (21 loc) · 751 Bytes
/
BhaskForm.java
File metadata and controls
24 lines (21 loc) · 751 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
package demo1;
import java.util.Scanner;
public class BhaskForm {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
double A = sc.nextDouble();
double B = sc.nextDouble();
double C = sc.nextDouble();
double delta = Math.pow(B, 2) - (4 * (A * C));
if (delta == 0 || delta < 0 || A == 0) {
System.out.println("Impossivel calcular");
} else {
double x = -B + Math.sqrt(delta);
double xlinha = x / (2 * A);
double x2 = -B - Math.sqrt(delta);
double xdualinha = x2 / (2 * A);
System.out.printf("R1 = %.5f\n", xlinha);
System.out.printf("R2 = %.5f\n", xdualinha);
}
}
}