public static String answer(boolean a, boolean b, boolean c, boolean d, boolean e)
{
String response;
if (a == true)
{
if (b == false)
{
if (c == true)
{
if (d == false)
{
if (e == true)
{
response = "Your animal is a goose!";
}
}
}
}
}
return response;
}
My problem is response. I want to return it to the main Tester, however it keeps saying it hasn't been initialized. I assume this means that it has been declared, right before the if else, but it's not recognizing the initialized variable inside it. how do I fix this?
This is written inside BlueJ, with Java. This program asks 5 questions (booleans a-e) to see which seven farm animals you are thinking of. The if statements determine your answers, and if they correspond, i want to return "response", which will print the animal you picked. Also, if there is a better way to do this, please inform me. I am new to Java, and coding, so any help is appreciated.