作业帮 > 综合 > 作业

write a program that converts a number in base 10 to its equ

来源:学生作业帮 编辑:大师作文网作业帮 分类:综合作业 时间:2024/11/17 18:01:20
write a program that converts a number in base 10 to its equivalent in base 2.
write a program that converts a number in base 10 to its equ
public class Du {
public static void main(String[] args) {
int num = 15;//十进制
String binaryStr = Integer.toBinaryString(num);//二进制
System.out.println(binaryStr);
}
}
再问: 我是想要个用键盘输入数字output二进制的程序,这个好像不是吧?
再答: import java.util.Scanner; public class Du { public static void main(String[] args) { System.out.print("Please input a digit number: "); int num = new Scanner(System.in).nextInt(); String binaryStr = Integer.toBinaryString(num); System.out.println(binaryStr); } }