Write a program OldMacDonald.java
that prints out 4–5 verses of the children’s song Old MacDonald. In this song, various farm animals and the sounds they make are placed into a series of verses. Here is one verse, for example:
Old MacDonald had a farm, ee-yi-ee-yi-oh
And on that farm he had a cow, ee-yi-ee-yi-oh
With a moo, moo here and a moo, moo there
Here a moo, there a moo, everywhere a moo, moo
Old MacDonald had a farm, ee-yi-ee-yi-oh
The main()
method of the program will call a method printVerse()
with a series of animals and noises:
printVerse("cow","moo");
printVerse("chicken","cluck");
printVerse("sheep","baa");
printVerse("dog","woof");
Write a printVerse()
method takes two parameters and uses them to print out the 5 lines of every verse with the appropriate animal and sound substituted in, along with a blank line at the end to separate each verse from the next.
Then run the program to display the verses of the song.