-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExer16.java
More file actions
40 lines (27 loc) · 880 Bytes
/
Exer16.java
File metadata and controls
40 lines (27 loc) · 880 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package com.laiane.cursojava.aula15;
import java.util.Scanner;
public class Exer16 {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
System.out.println("Entre com o valor de a:");
int a = scan.nextInt();
if (a== 0){
System.out.println("Não é uma equação de segundo grau");
} else {
System.out.println("Entre com o valor de b:");
int b = scan.nextInt();
System.out.println("Entre com o valor de c:");
int c = scan.nextInt();
double delta = (b*b) - (4*a*c);
if (delta < 0){
System.out.println("deltanegativo");
} else {
System.out.println("delta negativo");
double x1 = ((-b) + Math.sqrt (delta)) / (2*a);
double x2 = ((-b) - Math.sqrt (delta)) / (2*a);
System.out.println("x1= " + x1);
System.out.println("x2= " + x2);
}
}
}
}