repl.it
Java

URI Problem No: 1036

fork
loading
Files
  • Main.java
  • jdt.ls-java-project
Main.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import java.io.IOException;
import java.util.* ;

public class Main {
 
    public static void main(String[] args) throws IOException {
 
        Scanner input = new Scanner(System.in);
        
        double A = input.nextDouble();
        double B = input.nextDouble();
        double C = input.nextDouble();
        
        double del = B*B - 4*A*C;
        
        if (del < 0 || A == 0) {
            System.out.println("Impossivel calcular");
        } else {
            
            double R1 = (-B + Math.sqrt(del)) / (2*A);
            double R2 = (-B - Math.sqrt(del)) / (2*A);
            
            System.out.printf("R1 = %.5f\n", R1);
            System.out.printf("R2 = %.5f\n", R2);
        }
    }
}
?