-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathMultiplos.java
51 lines (38 loc) · 1.51 KB
/
Multiplos.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
/*
====================================================
Solucionando desafios matemáticos em Java
====================================================
4/5 - Múltiplos
====================================================
Leia 2 valores inteiros (A e B). Após, o programa deve mostrar uma mensagem "Sao Multiplos" ou "Nao sao Multiplos", indicando se os valores lidos são múltiplos entre si.
Entrada
A entrada contém valores inteiros.
Saída
A saída deve conter uma das mensagens conforme descrito acima.
--------------------------------------------
| Exemplo de Entrada | Exemplo de Saída |
--------------------------------------------
| 6 24 | Sao Multiplos |
--------------------------------------------
| 6 25 | Nao sao Multiplos |
--------------------------------------------
SOLUÇÃO ABAIXO: */
import java.io.IOException;
import java.util.Scanner;
public class Multiplos{
public static void main(String[] args) throws IOException {
Scanner leitor = new Scanner(System.in);
String[] valores = new String[2];
valores = leitor.nextLine().split(" ");
int valorA = Integer.parseInt(valores[0]);
int valorB = Integer.parseInt(valores[1]);
int resto = valorB%valorA;
int resto2 = valorA%valorB;
if (resto == 0 || resto2 == 0) {
System.out.println("Sao Multiplos");
} else {
System.out.println("Nao sao Multiplos");
}
leitor.close();
}
}