Read the loop you have written more closely. You are calling nextInt()
twice, once to get the value for x
and another time to call the addQuiz()
method:
while (x >= 0) {
x = sc.nextInt();
if (x >= 0) {
s.addQuiz(sc.nextInt());
}
else break;
}