/* Exer01.java CIS 160 David Klick 2015-09-02 Demonstrates formatting of output using printf Notes: %d is used for integers %f is used for floating point numbers %e is exponential format %% displays a percent sign %n outputs a newline (you could use \n instead) */ public class Exer01 { public static void main(String[] args) { int a = 17, b = 127; double x = 123.45678901234; System.out.printf("a: %9d%n", a); System.out.printf("b: %09d%n", b); System.out.printf("x: %9.2f%n", x); System.out.printf("x: %9.4f%n", x); System.out.printf("x: %9.2e%n", x); System.out.printf("5 is 50%% of 10%n"); } } /* Displays: a: 17 b: 000000127 x: 123.46 x: 123.4568 x: 1.23e+02 5 is 50% of 10 */