-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTrintaseis.java
More file actions
25 lines (17 loc) · 818 Bytes
/
Copy pathTrintaseis.java
File metadata and controls
25 lines (17 loc) · 818 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
package TodosExecicios;
//36. Escreva um programa para multiplicar dois números binários.
import java.util.Scanner;
public class Trintaseis {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("Digite o primeiro número binário: ");
String binario1 = scanner.next();
System.out.print("Digite o segundo número binário: ");
String binario2 = scanner.next();
int decimal1 = Integer.parseInt(binario1, 2);
int decimal2 = Integer.parseInt(binario2, 2);
int multiplicacaoDecimal = decimal1 * decimal2;
String multiplicacaoBinaria = Integer.toBinaryString(multiplicacaoDecimal);
System.out.println("A multiplicação dos números binários é: " + multiplicacaoBinaria);
}
}