Created
November 22, 2023 12:07
-
-
Save rafarocha/5951ef2a439e3a5fb3147fabddd667ca to your computer and use it in GitHub Desktop.
turma-1076-desafio01-feedback-deyse-ribeiro.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; | |
import java.lang.Math; | |
public class Main { | |
public static void main(String[] args) { | |
Scanner entrada = new Scanner(System.in); | |
float a; | |
float b; | |
float c; | |
double x1; | |
double x2; | |
System.out.println("Insira o primeiro numero,e.g 'a':"); | |
a = entrada.nextFloat(); | |
System.out.println("Insira o segundo numero,e.g 'b':"); | |
b = entrada.nextFloat(); | |
System.out.println("Insira o terceiro numero,e.g 'c':"); | |
c = entrada.nextFloat(); | |
x1 = (-b+Math.sqrt(b*b-4*a*c))/2*a; | |
x2 = (-b-Math.sqrt(b*b-4*a*c))/2*a; | |
System.out.println("As raizes são:\n"+"X1:"+x1+"\nX2:"+x2); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Revisão
Melhorias
(a,b,c)=(0,0,0)
indicouX1:0.0 e X2:-0.0
e deveria indicar não quadrática(a,b,c)=(0,0,0)
indicouX1:-8.0 e X2:-8.0
(a,b,c)=(2,1,5)
indicouX1:NaN e X2:NaN
e deveria indicar que não tem raízes(a,b,c)=(0,3,-2)
indicouX1:-2.895786426044878E7 e X2:-6.416348807395513E8
. Ver cenário 05(a,b,c)=(12345,-54321,9876)
indicouX1:0.0 e X2:-0.0
. Ver cenário 04(-b+Math.sqrt(b*b-4*a*c))/2*a
com a mudança de sinal incluindo numeradoresReferências