Created
November 22, 2023 12:33
-
-
Save rafarocha/d5e81671c27b66ed62e3f21ee7633970 to your computer and use it in GitHub Desktop.
turma-1076-desafio01-feedback-carlos-luis.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.println("Calculadora Bhaskara"); | |
System.out.print("Valor de a: "); | |
double a = input.nextDouble(); | |
System.out.print("Valor de b: "); | |
double b = input.nextDouble(); | |
System.out.print("Valor de c: "); | |
double c = input.nextDouble(); | |
if (a == 0) { | |
System.out.println("O valor de 'a' não pode ser igual a zero."); | |
} else { | |
double x1 = (-b + Math.sqrt(b * b - 4 * a * c)) / (2 * a); | |
double x2 = (-b - Math.sqrt(b * b - 4 * a * c)) / (2 * a); | |
System.out.println("As raízes são x1 = " + x1 + " e x2 = " + 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)=(4,4,1)
indicoux1 = -0.5 e x2 = -0.5
(a,b,c)=(2,1,5)
indicoux1 = NaN e x2 = NaN
. Ver cenário 03(-b + Math.sqrt(b * b - 4 * a * c)) / (2 * a)
com a mudança de sinal incluindo numeradoresReferências