-
-
Save folivetti/af755b9d59017001902ff51bcc328fc2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.IOException; | |
import java.util.Scanner; | |
public class Main { | |
public static void main(String[] args) throws IOException { | |
double A, B, C; | |
double delta, R1, R2; | |
Scanner sc = new Scanner(System.in); | |
A = sc.nextDouble(); | |
B = sc.nextDouble(); | |
C = sc.nextDouble(); | |
delta = B*B - 4*A*C; | |
if (delta < 0 || A == 0) { | |
System.out.println("Impossivel calcular"); | |
} else { | |
R1 = (-B + Math.sqrt(delta)) / (2*A); | |
R2 = (-B - Math.sqrt(delta)) / (2*A); | |
System.out.printf("R1 = %.5f\n", R1); | |
System.out.printf("R2 = %.5f\n", R2); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment