-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTrintaoito.java
More file actions
26 lines (19 loc) · 864 Bytes
/
Copy pathTrintaoito.java
File metadata and controls
26 lines (19 loc) · 864 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
package TodosExecicios;
//38. Escreva um programa para converter um número decimal em um número hexadecimal.
import java.util.Scanner;
public class Trintaoito {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("Digite um número decimal (somente com ou sem \",\") ");
double decimal = scanner.nextDouble();
int decimal1 = (int) decimal;
String hexa = Integer.toHexString(decimal1);
System.out.println("- 10 em hexadecimal é representado como a;\n"
+ "- 11 em hexadecimal é representado como b;\n"
+ "- 12 em hexadecimal é representado como c;\n"
+ "- 13 em hexadecimal é representado como d;\n"
+ "- 14 em hexadecimal é representado como e;\n"
+ "- 15 em hexadecimal é representado como f.\n");
System.out.println("O número hexadecimal é: " + hexa);
}
}