/* Method1.java CIS 160 Dave Klick 2004-10-18 user-defined methods returning values */ public class Method1 { public static void main(String[] args) { System.out.println(" n n * n n * n * n"); System.out.println("-- ----- ---------"); for (int i=1; i<=15; i++) { int sq = square(i); int cb = cube(i); System.out.println(pad(i, 2) + " " + pad(sq, 5) + " " + pad(cb, 9)); } } private static int square(int i) { return i * i; } private static int cube(int i) { return square(i) * i; } private static String pad(int i, int width) { String s = "" + i; while (s.length() < width) s = ' ' + s; return s; } }