Aligner les nombres à virgule

Author:


{filelink=6040}


public class AlignementNbrVir{
  public static void main(String[] argv) throws Exception {

    for (double i = 1.0; i < 20.0; i++)
      System.out.printf("%10.2f %10.2f %10.2f", i, Math.sqrt(i), i * i);

  }
}
/*    1.00       1.00       1.00
      2.00       1.41       4.00
      3.00       1.73       9.00
      4.00       2.00      16.00
      5.00       2.24      25.00
      6.00       2.45      36.00
      7.00       2.65      49.00
      8.00       2.83      64.00
      9.00       3.00      81.00
     10.00       3.16     100.00
     11.00       3.32     121.00
     12.00       3.46     144.00
     13.00       3.61     169.00
     14.00       3.74     196.00
     15.00       3.87     225.00
     16.00       4.00     256.00
     17.00       4.12     289.00
     18.00       4.24     324.00
     19.00       4.36     361.00
*/

A Voir sur le même Sujet:

  • formatage des sorites des nombres java
  • aligner des chiffre
  • aligner chiffres java system.out

Leave a Reply

Your email address will not be published. Required fields are marked *