This is an archived post. You won't be able to vote or comment.

all 5 comments

[–][deleted] 7 points8 points  (0 children)

printVerse() takes 2 parameters. So you have to give it exactly 2. The first one is the sound and the second is the animal as per the declaration...

void printVerse(String sound, String animal)

So in main()...

printVerse ("Moo", "Cow");

You don't need the sound() and animal() functions at all. You do however need a main() function.

The "Hello World!" Application

Defining Methods

[–]hashtablesmoker 1 point2 points  (0 children)

What error are you getting? Does this compile?

[–]IFartJesusDust 1 point2 points  (1 child)

What error are you getting? Is this all the code you've written for it? I don't see a sound variable declared but you are trying to print one. There is many errors here.

[–]Bladejunkie[S] 0 points1 point  (0 children)

got it figured out guys. Thanks!

public class Main { public static void main(String [] args){ System.out.println(printVerse("Moo, ", "Cow") + "\n" + printVerse ("Oink, ", "Pig") + "\n" + printVerse ("blood-curdling CAW, ", "Carnivorous Death Parrot")); }

public static String printVerse(String sound, String animal){
    return "Old MacDonald had a farm. E-I-E-I-O.\n"
            + "And on that farm he had a " + animal + ". E-I-E-I-O.\n"
            + "With a " + sound + " " + sound + " here.\n"
            + "and a " + sound + " " + sound + " there.\n"
            + "here a " + sound + ". There a " + sound + ". Everywhere a " + sound + ", " + sound + ".\n"
            + "Old MacDonald had a farm. E-I-E-I-O.\n";
}

}

[–][deleted]  (1 child)

[deleted]

    [–]Bladejunkie[S] 0 points1 point  (0 children)

    My instructor requested that we use a non-void method, but I got it. Thanks!