// Print the Old MacDonald song // Beth Katz - April 2009 public class MacD2D { public static final String[ ][ ] animal = { {"cow", "moo"}, {"dog", "woof"}, {"horse", "neigh"}, {"pig", "oink"}, {"hen", "cluck" } }; public static void main(String[] args) { for (int i = 0; i < animal.length; i++) { printSong(animal[i][0], animal[i][1]); } } // print the song with the given animal and sound public static void printSong(String animal, String sound) { System.out.println("Old MacDonald had a farm"); eieio( ); System.out.println("and on his farm, he had a " + animal); eieio( ); System.out.println("with a " + sound + " " + sound + " here"); System.out.println("and a " + sound + " " + sound + " there"); System.out.println("here a " + sound + " there a " + sound); System.out.println("everywhere a " + sound + " " + sound); System.out.println("Old MacDonald had a farm"); eieio( ); System.out.println( ); } // print the special letters public static void eieio( ) { System.out.println("E-I-E-I-O"); } }