-
Notifications
You must be signed in to change notification settings - Fork 18
/
Diferenca.java
57 lines (46 loc) · 1.89 KB
/
Diferenca.java
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/*
====================================================
Solucionando Desafios em Java
====================================================
1/3 - Diferença
====================================================
Leia quatro valores inteiros A, B, C e D. A seguir, calcule e mostre a diferença do produto de A e B pelo produto de C e D segundo a fórmula: DIFERENCA = (A * B - C * D).
Entrada
O arquivo de entrada contém 4 valores inteiros.
Saída
Imprima a mensagem DIFERENCA com todas as letras maiúsculas, conforme exemplo abaixo, com um espaço em branco antes e depois da igualdade.
--------------------------------------------
| Exemplo de Entrada | Exemplo de Saída |
--------------------------------------------
| 5 | DIFERENCA = -26 |
| 6 | |
| 7 | |
| 8 | |
--------------------------------------------
| 0 | DIFERENCA = -56 |
| 0 | |
| 7 | |
| 8 | |
--------------------------------------------
| 5 | DIFERENCA = 86 |
| 6 | |
| -7 | |
| 8 | |
--------------------------------------------
SOLUÇÃO ABAIXO: */
import java.io.IOException;
import java.util.Scanner;
public class Diferenca {
public static void main(String[] args) throws IOException {
Scanner leitor = new Scanner(System.in);
int a = leitor.nextInt();
int b = leitor.nextInt();
int c = leitor.nextInt();
int d = leitor.nextInt();
int ab = a * b;
int cd = c * d;
int diferenca = ab-cd;
System.out.println("DIFERENCA = "+ diferenca);
leitor.close();
}
}