I've had a ton of issues with this program, added a while hasNextInt, multiple other things and i've finally got the code working, but my output is just the first input, instead of max/avg of the inputs. Could somebody let me know where i'm messing up?
public class LabProgram {
public static void main(String[] args) {
Scanner scnr = new Scanner(System.in);
int count = 0, max = 0, total = 0;
int num = scnr.nextInt();
if (num >= 0) {
count++;
total += num;
max = Math.max(max, num);
num = scnr.nextInt();
}
int avg = count == 0 ? 0 : total/count;
System.out.println(avg + " " + max);
}
}