/* Method7.java CIS 160 Dave Klick 2004-10-18 overloading methods */ public class Method7 { public static void main(String[] args) { int n1 = 5; double n2 = 5.0; String n3 = "CIS 160"; procVar(n1); procVar(n2); procVar(n3); } private static void procVar(int n) { System.out.println("You passed in an integer: " + n); System.out.println("n * n = " + (n*n)); } private static void procVar(double n) { System.out.println("You passed in a double: " + n); System.out.println("n * n * n = " + (n*n*n)); } private static void procVar(String n) { System.out.println("You passed in a String: " + n); System.out.println(reverse(n)); } private static String reverse(String s) { String sout = ""; for (int i=s.length()-1; i>=0; i--) sout += s.charAt(i); return sout; } } /* Output: You passed in an integer: 5 n * n = 25 You passed in a double: 5.0 n * n * n = 125.0 You passed in a String: CIS 160 061 SIC */