Last active
November 22, 2023 12:45
-
-
Save rafarocha/22e5e6612ee41876f0eb6cc6c384bfa8 to your computer and use it in GitHub Desktop.
turma-1076-desafio01-feedback-clarice-copstein.java
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.util.Scanner; | |
public class Main { | |
public static void main(String[] args) { | |
Scanner input = new Scanner(System.in); | |
System.out.print("Digite o valor de 'a': "); | |
double a = input.nextDouble(); | |
System.out.print("Digite o valor de 'b': "); | |
double b = input.nextDouble(); | |
System.out.print("Digite o valor de 'c': "); | |
double c = input.nextDouble(); | |
double discriminante = b * b - 4 * a * c; | |
if (a == 0) { | |
System.out.println("A equação não é quadrática, 'a' não pode ser igual a zero."); | |
} else if (discriminante < 0) { | |
System.out.println("A equação não possui raízes reais."); | |
} else { | |
double x1 = (-b + Math.sqrt(discriminante)) / (2 * a); | |
double x2 = (-b - Math.sqrt(discriminante)) / (2 * a); | |
System.out.println("As raízes da equação são x1 = " + x1 + " e x2 = " + x2); | |
} | |
input.close(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Revisão
Melhorias
(a,b,c)=(4,4,1)
indicoux1 = -0.5 e x2 = -0.5
(-b + Math.sqrt(discriminante)) / (2 * a)
Referências