I am having trouble creating the code to end the program if the user enters -99. I have everything else done. The int "testNum" is what holds the value for -99. Can someone point me in the right direction on how to make it where when the user enters -99 then the program stops? Here is my code
import java.util.Scanner;
public class LargeSmall
{
public static void main(String[] args)
{
int numbers;
int smallest = 0;
int largest = 0;
int count = 0;
int val;
int testNum = -99;
int max;
Scanner keyboard = new Scanner(System.in);
System.out.println("How many numbers will you enter?");
max = keyboard.nextInt();
for (count = 0; count < max; count++)
{
System.out.println("Enter number ");
val = keyboard.nextInt();
if (val > largest)
{
largest = val;
}
if (val < smallest)
{
smallest = val;
}
}
System.out.println(smallest);
System.out.println(largest);
}
}