λ°μν
μ μ¬λ¬Έμ
- 10μ§μ μ λ ₯λ°μ 8μ§μ, 16μ§μλ‘ νννκΈ°
- 2μ§μ μ λ ₯λ°μ 10μ§μλ‘ νννκΈ°
λͺ©ν
μ½λ
- Integer ν΄λμ€ APIλ₯Ό μ¬μ©νκΈ°
- κ²°κ΅ 10μ§μλ§ int ν, λλ¨Έμ§λ String νμΌλ‘ ννλλ€λ κ² μ μ
package JavaFestival;
import java.util.Scanner;
public class test1 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("μ«μ μ
λ ₯ >> ");
int num = sc.nextInt();
String numBinary = Integer.toBinaryString(num);
String numOctal = Integer.toOctalString(num);
String numHex = Integer.toHexString(num);
System.out.printf("10μ§μ : %d, 2μ§μ : %s ",num, numBinary);
System.out.println();
System.out.printf("8μ§μ : %s, 16μ§μ : %s ",numOctal, numHex);
}
}
κ²°κ³Ό
μ«μ μ
λ ₯ >>
55
10μ§μ : 55, 2μ§μ : 110111
8μ§μ : 67, 16μ§μ : 37
λ°μν