-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtres.java
More file actions
27 lines (19 loc) · 896 Bytes
/
tres.java
File metadata and controls
27 lines (19 loc) · 896 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
import java.util.Scanner;
public class tres {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("Digite o primeiro valor: ");
double primeiroValor = scanner.nextDouble();
double segundoValor = 0;
while (segundoValor == 0) {
System.out.print("Digite o segundo valor (nao pode ser zero): ");
segundoValor = scanner.nextDouble();
if (segundoValor == 0) {
System.out.println("VALOR INVALIDO. O segundo valor nao pode ser zero.");
}
}
double resultado = primeiroValor / segundoValor;
System.out.printf("O resultado da divisao de %.2f por %.2f e: %.2f%n", primeiroValor, segundoValor, resultado);
scanner.close();
}
}