wondering if anyone can help me with this. The goal of this program is to allow a user to input a list of numbers ending it with a negative number as the trigger to execute the calculations. The calculations include finding the average of the list, the largest number and the smallest number, but none of the calculations can include the negative number. I've figured out how to get the largest number and the average but my code for smallest number isn't working. Can anyone tell me what will work or at least point me in the right direction? here's what i've got so far.

/* * Robert Durning * HW4a */ //Determine Small, Large, Average values for a list of integers import java.util.*; public class SmLrgAvg { public static void main(String[] args) { Scanner keyboard = new Scanner(System.in); System.out.println("Enter in a list of non-negative integers. End the list with a negative integer."); int n = 0, count = 0; double largestInteger = 0, smallestInteger = n, sum = 0; while (n >= 0) { n = keyboard.nextInt(); smallestInteger = n; if (n >= 0) { sum = sum + n; count = count + 1; } if (n >= largestInteger) largestInteger = n; if (n < smallestInteger && n >= 0) smallestInteger = n; } System.out.println("The largest integer is: " + largestInteger); System.out.println("The smallest integer is: " + smallestInteger); System.out.println("The average of your list is: " + sum/count); } }

thanks