Méthode ‘printf’: Aligner les nombre à virgule

Author:


{filelink=6013}

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

    for (double i = 5.0; i < 200.0; i+=5)
      System.out.printf("%10.2f %10.2f %10.2fn", i, Math.sqrt(i), i * i);

  }
}
/*
 *  Sortie Console:
 *   5,00       2,24      25,00
     10,00       3,16     100,00
     15,00       3,87     225,00
     20,00       4,47     400,00
     25,00       5,00     625,00
     30,00       5,48     900,00
     35,00       5,92    1225,00
     40,00       6,32    1600,00
     45,00       6,71    2025,00
     50,00       7,07    2500,00
     55,00       7,42    3025,00
     60,00       7,75    3600,00
     65,00       8,06    4225,00
     70,00       8,37    4900,00
     75,00       8,66    5625,00
     80,00       8,94    6400,00
     85,00       9,22    7225,00
     90,00       9,49    8100,00
     95,00       9,75    9025,00
    100,00      10,00   10000,00
    105,00      10,25   11025,00
    110,00      10,49   12100,00
    115,00      10,72   13225,00
    120,00      10,95   14400,00
    125,00      11,18   15625,00
    130,00      11,40   16900,00
    135,00      11,62   18225,00
    140,00      11,83   19600,00
    145,00      12,04   21025,00
    150,00      12,25   22500,00
    155,00      12,45   24025,00
    160,00      12,65   25600,00
    165,00      12,85   27225,00
    170,00      13,04   28900,00
    175,00      13,23   30625,00
    180,00      13,42   32400,00
    185,00      13,60   34225,00
    190,00      13,78   36100,00
    195,00      13,96   38025,00
*/

A Voir sur le même Sujet:

  • printf aligner
  • comment aligner nombres à différentes variables
  • +c# +format +string +aligner +virgule
  • alignement texte java printf
  • aligner les chiffres dans un fichier textedans windows
  • printf nombre virgule
  • locale virgule nombre printf
  • méthode printf
  • prinf nombre virgule perl
  • printf float nombre décimal

Leave a Reply

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