This is my assignment:
Write a method called validate that accepts three integer parameters. The first two parameters represent a range, and the purpose of the method is to verify that the value of the third parameter is in that range. You may assume that the first parameter is less than or equal to the second. If the third parameter is not in the specified range, the method should prompt the user and read a new value. This new value should be tested for validity as well. The method should only return to the calling method once a valid value has been obtained, and it should return the valid value.
This is what I have so far:
{
public int validate (int x, int y, int z)
{
while((z < x) || (z > y))
return z;
}
}
I am really bad in Java and have no idea if I am heading in the right direction on this, but how would I make it so I can return the z? Any help would be appreciated