集册 Java实例教程 格式化数字,右对齐,十进制

格式化数字,右对齐,十进制

欢马劈雪     最近更新时间:2020-01-02 10:19:05

540
格式化数字,右对齐,十进制

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 - 
展开阅读全文