Created
November 22, 2023 11:46
-
-
Save rafarocha/b1d85fc631819cbbdde3a6385454cdaf to your computer and use it in GitHub Desktop.
turma-1076-desafio01-feedback-patricia-ferreira.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
public class Main { | |
public static void main(String[] args) { | |
// (-b2 +_(4*a*c)) / 2*a | |
int a=4; | |
int b=4; | |
int c=1; | |
double delta = Math.pow(b,2) - (4*a*c); | |
double denominador = 2*a; | |
double numeradorx1 = -b+Math.sqrt(delta); | |
double numeradorx2 = -b-Math.sqrt(delta); | |
double x1 = numeradorx1/denominador; | |
double x2 = numeradorx2/denominador; | |
if (delta>=0){ | |
if (x1 == x2){ | |
System.out.println("X1 = X2 = "+String.format("%.2f",x1)); | |
}else { | |
System.out.println("X1 = "+ x1); | |
System.out.println( "X2 = "+x2); | |
} | |
}else { | |
System.out.println("Não existe raíz real"); | |
} | |
} | |
} |
Obrigada, Rocha! Vou ler o material que você recomendou.
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 = X2 = -0.50
-b+Math.sqrt(delta)
com a mudança de sinal incluindo numeradores// (-b2 +_(4*a*c)) / 2*a
Referências