格式化数字,右对齐,十进制
import java.util.Scanner; /* from n o w j a v a . c o m - 时代Java*/ public class Main { public static void main(String[] args) { @SuppressWarnings("resource") Scanner userInput = new Scanner(System.in); int a = userInput.nextInt(); double b = userInput.nextDouble(); double c = userInput.nextDouble(); String aHex = ""; String aBin = ""; if ((a >= 0) && (a <= 500)) { aHex = Integer.toHexString(a).toUpperCase(); aBin = String.format("%10s", Integer.toBinaryString(a)).replace(" ", "0"); } else { /* 来自 *N o w J a v a . c o m -