3-20 LeftJustified

posted Feb 1, 2014, 6:51 AM by Dlovan ismail   [ updated Feb 1, 2014, 6:51 AM by Karwan Jacksi ]
/*
This program displays a variety of
numbers left - justified in columns.
*/

package leftjustified;

public class LeftJustified 
{
    public static void main(String[] args)
    {
            // Declare a variety of int variables.
            int numl = 123;
            int num2 = 12;
            int num3 = 45678;
            int num4 = 456;
            int num5 = 1234567;
            int num6 = 1234;

           // Display each variable left-juatified
           // in a field of 8 spaces.
            System.out.printf("%-8d%-8d\n",numl,num2);
            System.out.printf("%-8d%-8d\n",num3,num4);
            System.out.printf("%-8d%-8d\n",num5,num6);
    }   
}

ċ
LeftJustified.java
(1k)
Karwan Jacksi,
Feb 1, 2014, 6:51 AM
Comments