your code so far
int userNumber; //user entered number
int largestSoFar = 0; //Keeps track of largest number entered
int smallestSoFar = 500; //Keeps track of smallest number entered
final int SENTINEL = -99;
//Assume user puts int inside userNumber
while (userNumber != SENTINEL)
{
if (userNumber > largestSoFar)
largestSoFar = userNumber;
if (userNumber < smallestSoFar)
smallestSoFar = userNumber;
//Assume user puts int inside userNumber
}
so your code does well to continue until the user flags it to stop, and is correct unless someone never enters a number larger then 0 or never smaller then 500.
to fix this, unless your teacher gives you a default value, they have to start uninitialized.
int largestSoFar;
int smallestSoFar;
this brings a new problem that you have to deal with, which is what if the first input is -99! your while loop never gets entered, so you need to think about how to handle that, it seems like a "special case" that an if statement might be up to solving on his own.
Hope this helps,
Jonathan