import java.io.PrintStream;

/**
 * An example that illustrates the use of the printf()
 * method in the PrintStream class
 *
 * @author  Prof. David Bernstein, James Madison University
 * @version 1.0
 */
public class PrintfExample
{
    /**
     * The entry point of the application
     *
     * @param args   The command-line arguments
     */
    public static void main(String[] args)
    {
       int     age, weight;
       double  monday, tuesday, wednesday;
       
       age = 27;
       
       System.out.printf("%d\n", age);
       System.out.printf("%10d\n", age);
       
       weight = 155;
       
       System.out.printf("Prof. B. is %d years old\n", age);
       System.out.printf("Age: %d\tWeight: %d\n", age, weight);
       

       monday    =  35.8;
       tuesday   =   0.0;
       wednesday = -10.2;

       System.out.println("\nWith No Flags, Width or Precision");       
       System.out.printf("%f\n", monday);
       System.out.printf("%f\n", tuesday);
       System.out.printf("%f\n", wednesday);

       System.out.println("\nWith No Flags");       
       System.out.printf("%5.1f\n", monday);
       System.out.printf("%5.1f\n", tuesday);
       System.out.printf("%5.1f\n", wednesday);

       System.out.println("\nWith + Flags");       
       System.out.printf("%+5.1f\n", monday);
       System.out.printf("%+5.1f\n", tuesday);
       System.out.printf("%+5.1f\n", wednesday);
    }
}
