26.7k views
3 votes
Rewrite this method so that it avoids the use of a return statement:

void divisionQuestion()
{
int x, y;
x = (int)random(-10, 11);
y = (int)random(-10, 11);
if (y == 0)
{
println("Sorry we chose 0 for the denominator");
return;
}
else
println(x + " divided by " + y + " is " + x / y);
}

User Sam Jarman
by
6.9k points

1 Answer

1 vote
Sorry we chose 0 for the denominator
User Tohava
by
6.5k points