// Print the Old MacDonald song // Beth Katz - April 2009 public class MacD { public static final String[ ] animal = {"cow", "dog", "horse", "pig", "hen"}; public static final String[ ] sound = {"moo", "woof", "neigh", "oink", "cluck"}; public static void main(String[] args) { for (int i = 0; i < animal.length; i++) { printSong(animal[i], sound[i]); } } // 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"); } }