when I execute this program, it prints the max value just fine, however the min value always prints to zero. I continue to scratching my head... Can anyone see what is wrong here? Thanks for looking.
import java.util.Scanner;
public class MinMax
{
public static void main(String[] args)
{
Scanner kb = new Scanner(System.in);
int [] numbers = new int[5];
int max = numbers[0];
int min = numbers[0];
for (int i = 0; i < numbers.length; i++)
{
System.out.println("Enter your next number:");
numbers[i] = kb.nextInt();
if (numbers[i] > max)
{
max = numbers[i];
}
if (min > numbers[i])
{
min = numbers[i];
}
}
System.out.println("The maximum value in your array is " + max);
System.out.println("The minimum value in your array is " + min);
}
}