#When I call a method in an if statement in the main method it keeps repeating

1 messages · Page 1 of 1 (latest)

final bronze
#

Below is my code. I'm trying to utilize an if statement to just check to see which method the user wants to call. However, when they put 1 it works fine, but when they put 2 it repeats the question once then it displays the correct output. And if they put 3 it repeats twice and then displays the correct output. I just want it to display once no matter what question they put.

https://codeshare.io/wnVrdB

eager egretBOT
#

Hey, @final bronze!
Please remember to /close this post once your question has been answered!

restive fox
#

try

#

int extra = ExtraQuestion(0);
if (extra == 1) {
Birthday(null);
}
else if (extra == 2) {
Number(0);
}
else if (extra == 3) {
Pets(0);
}
else {
System.out.println("Invalid Submission. (Did you make a typo?)");
}

#

you ask the user every tyime

#

wehen you do 3 times
ExtraQuestion(0)
the programm call it three time
but when a if was answerd with true the programm doesnt checks the other ones

final bronze
#

Ohhh okay, so basically create a variable instead calling the class

#

I'll try that

#

This worked @restive fox - thank you so much!!